您将允许持久操作的非持久数据结构称为什么?
我有一个本质上可变的类,但允许一些“类似持久”的操作。 例如,我可以像这样改变对象(在Python中):
# create an object with y equal to 3 and z equal to "foobar"
x = MyDataStructure(y = 3, z = "foobar")
x.y = 4
但是,代替以这种方式做事,有几种方法可以制作副本然后改变它:
x = MyDataStructure(y=3, z="foobar")
# a is just like x, but with y equal to 4.
a = x.using(y = 4)
这是用不同的方式复制x价值观。 显然,这不符合维基百科给出的部分持久的定义。
那么你会怎么称呼这样的课程呢? 准持久对象? 持久化对象? 持久对象排序? 更好的是,有这方面的技术名称吗?
I've got a class that is essentially mutable, but allows for some "persistent-like" operations. For example, I can mutate the object like this (in Python):
# create an object with y equal to 3 and z equal to "foobar"
x = MyDataStructure(y = 3, z = "foobar")
x.y = 4
However, in lieu of doing things this way, there are a couple of methods that instead make a copy and then mutate it:
x = MyDataStructure(y=3, z="foobar")
# a is just like x, but with y equal to 4.
a = x.using(y = 4)
This is making a duplicate of x with different values. Apparently, this doesn't meet the definition of partially persistent given by wikipedia.
So what would you call a class like this? QuasiPersistentObject? PersistableObject? SortOfPersistentObject? Better yet, are there any technical names for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将这种数据称为持久,但不确定这是否是一个词
。
I call this kind of data Persistable but not sure if it's a word
.
这只是一个优化的副本,我宁愿重命名该操作以反映这一点。
It's just a optimized copy, I'd rather rename the operation to reflect that.