storeString equivalent without duplicates

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

storeString equivalent without duplicates

Mateusz Grotek
Hi,
Is there any ready-made solution for the following problem.
I'd like to generate the source code which when evaluated returns an  
object in a similar way to what storeString does.
The difference is, that currently storeString creates duplicates.
For example, let's say I have created an array in the following way:

   element := Object new.
   array := {element. element}.

Now if I print:

   array storeString

it shows:

   '((Array new: 2) at: 1 put: (Object basicNew yourself); at: 2 put:  
(Object basicNew yourself); yourself)'

so there is the following inconsistency:

   array2 := Compiler evaluate: array storeString.
   array first == array second. "true"
   array2 first == array2 second. "false"

If there is no ready-made solution, I'll have to hack one myself.

Best wishes,
Mateusz
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: storeString equivalent without duplicates

Levente Uzonyi-2
Why don't you use one of the existing object serialization methods for
this? E.g. Fuel, ReferenceStream or ImageSegments.

Levente

On Wed, 15 Apr 2015, Mateusz Grotek wrote:

> Hi,
> Is there any ready-made solution for the following problem.
> I'd like to generate the source code which when evaluated returns an object
> in a similar way to what storeString does.
> The difference is, that currently storeString creates duplicates.
> For example, let's say I have created an array in the following way:
>
> element := Object new.
> array := {element. element}.
>
> Now if I print:
>
> array storeString
>
> it shows:
>
> '((Array new: 2) at: 1 put: (Object basicNew yourself); at: 2 put: (Object
> basicNew yourself); yourself)'
>
> so there is the following inconsistency:
>
> array2 := Compiler evaluate: array storeString.
> array first == array second. "true"
> array2 first == array2 second. "false"
>
> If there is no ready-made solution, I'll have to hack one myself.
>
> Best wishes,
> Mateusz
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners