Author |
Message |
Ivan Tome #1 / 15
|
 Save object?
Hi, Saving an object in a file seems such a common (and frequently expressed) need that it seems to me that it would be appropriate to define a method for it in Object. For example, saveUsing: aStorer in: aFilename. Or possibly more specifically, for example in VW, storeUsingBossIn: aFilename. Do you think that this is objectionable? Ivan
|
Wed, 21 Apr 2004 00:19:21 GMT |
|
 |
Károly Ladvánszk #2 / 15
|
 Save object?
Hi, A funny coincidence, I have just posted my message next to you, without reading yours first and part of my message is about object persistence too. I have played with python for a bit of time and I find it's support for object persistence a very strong feature. I suspect that some sort of persistence is already present in Smalltalk or is saving the image a different thing?
Quote: > Hi, > Saving an object in a file seems such a common (and frequently > expressed) need that it seems to me that it would be appropriate to > define a method for it in Object. For example, saveUsing: aStorer in: > aFilename. Or possibly more specifically, for example in VW, > storeUsingBossIn: aFilename. Do you think that this is objectionable? > Ivan
______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net
|
Wed, 21 Apr 2004 03:02:29 GMT |
|
 |
David Simmon #3 / 15
|
 Save object?
Quote: > Hi, > Saving an object in a file seems such a common (and frequently > expressed) need that it seems to me that it would be appropriate to > define a method for it in Object. For example, saveUsing: aStorer in: > aFilename. Or possibly more specifically, for example in VW, > storeUsingBossIn: aFilename. Do you think that this is objectionable? > Ivan
In QKS Smalltalk this was called: |blob| := anObject Archive. "" An object cluster Or more generally: (PIPO new) rootList: ...some set of objects...; generateArchive. The PIPO [Platform Independent Package of Objects] class allows creating arbitrary sectioned, versioned, signed repositories. The objects and other data within it can be randomly accessed or extracted as an entire package. In effect the PIPO is a mini-image. They are very fast, lightweight, and formed the basis of the Agent technology of SmalltalkAgents and the Agents Object System. The PIPO class was also written entirely in Smalltalk. There are good technical reasons why you don't want something simple like: anObject archiveOn: someStream. Specifically, the stream doesn't handle cycles, futures, versioning, etc. It is straightforward to create a "quasi-stream" that actually builds a PIPO. If you need to write structures directly onto a data stream, then we also facilities doing that but they were almost never used given the power and performance of PIPO's. -- Dave S. [www.smallscript.org]
|
Wed, 21 Apr 2004 16:54:01 GMT |
|
 |
Cees de Gro #4 / 15
|
 Save object?
Quote: >A funny coincidence, I have just posted my message next to you, without >reading yours first and part of my message is about object persistence too. >I have played with Python for a bit of time and I find it's support for >object persistence a very strong feature. I suspect that some sort of >persistence is already present in Smalltalk or is saving the image a >different thing?
Personally, I think persistence is a bit more than what the Python pickle module provides - but Smalltalk has the same stuff. In VisualWorks, there are two facilities. One writes Smalltalk expressions to recreate the object: | strm | strm := WriteStream on: (String new: 1024). Dictionary new at: #foo put: '123'; at: #bar put: 123; storeOn: strm. strm contents inspect. And the other one is more like pickle, it marshalls objects in an optimized low-level binary format: strm := WriteStream on: (ByteArray new: 1024). strm binary. bos := BinaryObjectStorage onNew: strm. bos nextPut: (Dictionary new at: #foo put: '123'; at: #bar put: 123; yourself). strm contents inspect. --
GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B
|
Wed, 21 Apr 2004 20:17:58 GMT |
|
 |
Károly Ladvánszk #5 / 15
|
 Save object?
Thank you for your very helpful answer. Quote: > Personally, I think persistence is a bit more than what the Python pickle > module provides - but Smalltalk has the same stuff. In VisualWorks, there > are two facilities. One writes Smalltalk expressions to recreate the > object:
Could you explain your view about persistence, please? Cheers, Kroly ______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net
|
Wed, 21 Apr 2004 22:08:39 GMT |
|
 |
Ivan Tome #6 / 15
|
 Save object?
The second method - with BOSS (BinaryObjectStreamingService) is the more compact and more efficient and generally preferred way. It saves the object in binary (the first method saves it as a string) and can handle most kinds of compound objects. Extending what Cees said, saving an object in a file would look like this: stream := nameString asFilename writeStream. boss := BinaryObjectStorage onNew: stream. boss nextPut: anObject. stream close and loading it back is equally simple. My point was that although it is simple, it's a bit annoying to have to type these four lines every time instead of someting like anObject saveUsingBossInFile: aFilename. Ivan Quote:
> Thank you for your very helpful answer. > > Personally, I think persistence is a bit more than what the Python pickle > > module provides - but Smalltalk has the same stuff. In VisualWorks, there > > are two facilities. One writes Smalltalk expressions to recreate the > > object: > Could you explain your view about persistence, please? > Cheers, > Kroly > ______________________________________________________________________________ > Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net
|
Wed, 21 Apr 2004 23:31:49 GMT |
|
 |
James A. Robertso #7 / 15
|
 Save object?
Quote:
> The second method - with BOSS (BinaryObjectStreamingService) is the more compact > and more efficient and generally preferred way. It saves the object in binary (the > first method saves it as a string) and can handle most kinds of compound objects. > Extending what Cees said, saving an object in a file would look like this: > stream := nameString asFilename writeStream. > boss := BinaryObjectStorage onNew: stream. > boss nextPut: anObject. > stream close > and loading it back is equally simple. > My point was that although it is simple, it's a bit annoying to have to type these > four lines every time instead of someting like > anObject saveUsingBossInFile: aFilename.
Then just add that method to Object Quote: > Ivan
>>Thank you for your very helpful answer. >>>Personally, I think persistence is a bit more than what the Python pickle >>>module provides - but Smalltalk has the same stuff. In VisualWorks, there >>>are two facilities. One writes Smalltalk expressions to recreate the >>>object: >>Could you explain your view about persistence, please? >>Cheers, >>Kroly >>______________________________________________________________________________ >>Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net
|
Wed, 21 Apr 2004 23:39:04 GMT |
|
 |
Ivan Tome #8 / 15
|
 Save object?
Yes, of course. I was just wondering whether other people though that it would generally be a good idea. Ivan Quote:
> > The second method - with BOSS (BinaryObjectStreamingService) is the more compact > > and more efficient and generally preferred way. It saves the object in binary (the > > first method saves it as a string) and can handle most kinds of compound objects. > > Extending what Cees said, saving an object in a file would look like this: > > stream := nameString asFilename writeStream. > > boss := BinaryObjectStorage onNew: stream. > > boss nextPut: anObject. > > stream close > > and loading it back is equally simple. > > My point was that although it is simple, it's a bit annoying to have to type these > > four lines every time instead of someting like > > anObject saveUsingBossInFile: aFilename. > Then just add that method to Object > > Ivan
> >>Thank you for your very helpful answer. > >>>Personally, I think persistence is a bit more than what the Python pickle > >>>module provides - but Smalltalk has the same stuff. In VisualWorks, there > >>>are two facilities. One writes Smalltalk expressions to recreate the > >>>object: > >>Could you explain your view about persistence, please? > >>Cheers, > >>Kroly > >>______________________________________________________________________________ > >>Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net
|
Thu, 22 Apr 2004 00:15:29 GMT |
|
 |
Andy Bowe #9 / 15
|
 Save object?
Ivan, Quote: > Yes, of course. I was just wondering whether other people though that it would generally > be a good idea. > Ivan
Dolphin includes some methods of Object to do this. We have: Object>>binaryStoreOn: aStream Object>>binaryStoreBytes These use the Dolphin STB mechanism (which is pretty similar to VW's BOSS). The latter is just a shortcut to save an object to a ByteArray. There are appropriate messages in Object class to reconstitute the saved object at a later date: Object class binaryReadFrom: aStream Object class fromBinaryStoreBytes: aByteArray My only point about the efficacy of such methods is this. They are only suitable for saving down objects that are easily extracted from the surrounding net of additional objects. That is, if you attempt to save down something that contains references to other objects outside its local net then you can end up storing a lot more than you bargain for. The Dolphin STB mechanism (and BOSS) provide means by which this can be controlled but not all of them are suitable for use with the above methods. For example, if you choose to save down a window object (a View in Dolphin's case) then, when you come to restore it again, this can only be done within the context of a parent window. Hence, you need additional methods such as: Object class binaryReadFrom: aStream context: anObject This works for the simple case where there is only one possible context (the parent window in this example) but other objects may need to be stitched back into the image in more complex ways. Best Regards, Andy Bower Object Arts Ltd. http://www.object-arts.com --- Are you trying too hard? http://www.object-arts.com/Relax.htm --- Quote:
> > > The second method - with BOSS (BinaryObjectStreamingService) is the more compact > > > and more efficient and generally preferred way. It saves the object in binary (the > > > first method saves it as a string) and can handle most kinds of compound objects. > > > Extending what Cees said, saving an object in a file would look like this: > > > stream := nameString asFilename writeStream. > > > boss := BinaryObjectStorage onNew: stream. > > > boss nextPut: anObject. > > > stream close > > > and loading it back is equally simple. > > > My point was that although it is simple, it's a bit annoying to have to type these > > > four lines every time instead of someting like > > > anObject saveUsingBossInFile: aFilename. > > Then just add that method to Object > > > Ivan
> > >>Thank you for your very helpful answer. > > >>>Personally, I think persistence is a bit more than what the Python pickle > > >>>module provides - but Smalltalk has the same stuff. In VisualWorks, there > > >>>are two facilities. One writes Smalltalk expressions to recreate the > > >>>object: > > >>Could you explain your view about persistence, please? > > >>Cheers, > > >>Kroly >>__________________________________________________________________________ ____ > > >>Posted Via Binaries.net = SPEED+RETENTION+COMPLETION =
http://www.binaries.net
|
Thu, 22 Apr 2004 02:52:17 GMT |
|
 |
Cees de Gro #10 / 15
|
 Save object?
Quote: >> Personally, I think persistence is a bit more than what the Python pickle >> module provides - but Smalltalk has the same stuff. In VisualWorks, there >> are two facilities. One writes Smalltalk expressions to recreate the >> object: >Could you explain your view about persistence, please?
It's a sort of slider, probably - marshalling on the left, an OODB on the right, and persistence somewhere in the middle. I'm quite fuzzy about the exact borders (as far as they're there), that's why I used the words "Personally" and "I think" ;-) (cheap cop-out, but hey - it's Sunday morning 1:30am and I just stuffed my brains with back issues of the Smalltalk chronicles). Think object identity, value/reference storing, indexing, transactions as some items that determine the position of the slide on the scale. --
GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B
|
Thu, 22 Apr 2004 08:43:00 GMT |
|
 |
Denis Johnso #11 / 15
|
 Save object?
Many here have already contributed viable solutions but also consider this dialect independent approach: http://wiki.cs.uiuc.edu/CampSmalltalk/Binary+standard+for+object+inte... Regards Denis
Quote: > Hi, > Saving an object in a file seems such a common (and frequently > expressed) need that it seems to me that it would be appropriate to > define a method for it in Object. For example, saveUsing: aStorer in: > aFilename. Or possibly more specifically, for example in VW, > storeUsingBossIn: aFilename. Do you think that this is objectionable? > Ivan
|
Fri, 23 Apr 2004 08:08:54 GMT |
|
 |
Vlastimil Adamovsk #12 / 15
|
 Save object?
I am not using BOSS but I have a question : Can BOSS save objects with circular references ? Vlastik
Quote: > The second method - with BOSS (BinaryObjectStreamingService) is the more compact > and more efficient and generally preferred way. It saves the object in binary (the > first method saves it as a string) and can handle most kinds of compound objects. > Extending what Cees said, saving an object in a file would look like this: > stream := nameString asFilename writeStream. > boss := BinaryObjectStorage onNew: stream. > boss nextPut: anObject. > stream close > and loading it back is equally simple. > My point was that although it is simple, it's a bit annoying to have to type these > four lines every time instead of someting like > anObject saveUsingBossInFile: aFilename. > Ivan
> > Thank you for your very helpful answer. > > > Personally, I think persistence is a bit more than what the Python pickle > > > module provides - but Smalltalk has the same stuff. In VisualWorks, there > > > are two facilities. One writes Smalltalk expressions to recreate the > > > object: > > Could you explain your view about persistence, please? > > Cheers, > > Kroly
____________________________________________________________________________ __ Quote: > > Posted Via Binaries.net = SPEED+RETENTION+COMPLETION =
http://www.binaries.net
|
Sat, 24 Apr 2004 10:04:02 GMT |
|
 |
Chris Lopema #13 / 15
|
 Save object?
Yes Quote:
> I am not using BOSS but I have a question : Can BOSS save objects with > circular references ? > Vlastik
> > The second method - with BOSS (BinaryObjectStreamingService) is the more > compact > > and more efficient and generally preferred way. It saves the object in > binary (the > > first method saves it as a string) and can handle most kinds of compound > objects. > > Extending what Cees said, saving an object in a file would look like this: > > stream := nameString asFilename writeStream. > > boss := BinaryObjectStorage onNew: stream. > > boss nextPut: anObject. > > stream close > > and loading it back is equally simple. > > My point was that although it is simple, it's a bit annoying to have to > type these > > four lines every time instead of someting like > > anObject saveUsingBossInFile: aFilename. > > Ivan
> > > Thank you for your very helpful answer. > > > > Personally, I think persistence is a bit more than what the Python > pickle > > > > module provides - but Smalltalk has the same stuff. In VisualWorks, > there > > > > are two facilities. One writes Smalltalk expressions to recreate the > > > > object: > > > Could you explain your view about persistence, please? > > > Cheers, > > > Kroly > ____________________________________________________________________________ > __ > > > Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = > http://www.binaries.net
|
Sat, 24 Apr 2004 22:27:19 GMT |
|
 |
Chris Lopema #14 / 15
|
 Save object?
I looked at this a while back as a replacement for BOS. It looked pretty nice. At the time there were a couple of things it could not do that BOS did. Paul seemed open to making changes. And it may even be better now. But I was in a rush at the time and just made BOS work. Quote:
> Many here have already contributed viable solutions but also consider this > dialect independent approach: > http://wiki.cs.uiuc.edu/CampSmalltalk/Binary+standard+for+object+inte... > Regards Denis
> > Hi, > > Saving an object in a file seems such a common (and frequently > > expressed) need that it seems to me that it would be appropriate to > > define a method for it in Object. For example, saveUsing: aStorer in: > > aFilename. Or possibly more specifically, for example in VW, > > storeUsingBossIn: aFilename. Do you think that this is objectionable? > > Ivan
|
Sat, 24 Apr 2004 22:30:38 GMT |
|
 |
Sean Morris #15 / 15
|
 Save object?
If I could make a suggestion, I think you should make the protocol expect a WriteStream instead of String (filename). This would allow for streaming to memory, a socket, etc. You could clearly express saving to a file as (if the method answers the stream): (myObject saveUsingBOSSToStream: string asFilename writeStream) close. Sean Quote:
> Yes, of course. I was just wondering whether other people though that it would generally > be a good idea. > Ivan
> > > The second method - with BOSS (BinaryObjectStreamingService) is the more compact > > > and more efficient and generally preferred way. It saves the object in binary (the > > > first method saves it as a string) and can handle most kinds of compound objects. > > > Extending what Cees said, saving an object in a file would look like this: > > > stream := nameString asFilename writeStream. > > > boss := BinaryObjectStorage onNew: stream. > > > boss nextPut: anObject. > > > stream close > > > and loading it back is equally simple. > > > My point was that although it is simple, it's a bit annoying to have to type these > > > four lines every time instead of someting like > > > anObject saveUsingBossInFile: aFilename. > > Then just add that method to Object > > > Ivan
> > >>Thank you for your very helpful answer. > > >>>Personally, I think persistence is a bit more than what the Python pickle > > >>>module provides - but Smalltalk has the same stuff. In VisualWorks, there > > >>>are two facilities. One writes Smalltalk expressions to recreate the > > >>>object: > > >>Could you explain your view about persistence, please? > > >>Cheers, > > >>Kroly > > >>______________________________________________________________________________ > > >>Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net
|
Sun, 25 Apr 2004 02:25:04 GMT |
|
|
|