Jason Baker
Jason Baker

Reputation: 198707

What would you call a non-persistent data structure that allows persistent operations?

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?

Upvotes: 4

Views: 444

Answers (2)

Jochen Ritzel
Jochen Ritzel

Reputation: 107666

It's just a optimized copy, I'd rather rename the operation to reflect that.

a = x.copy_with(y=4)

Upvotes: 2

ZZ Coder
ZZ Coder

Reputation: 75496

I call this kind of data Persistable but not sure if it's a word .

Upvotes: 2

Related Questions