[Oharo-users] Copy AST

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

[Oharo-users] Copy AST

Mark Rizun
Hi everyone,

I want to get a deep copy of ast. But deepCopy doesn't work:)
What I mean:

| ast1 ast2 |
ast1 := RBParser parseRewriteExpression: 'self'.
ast2 := ast1 copy."or without copy"
ast1 stop: 99.
ast2 stop

When evaluate this you get 99. I want it to be 4.
So I want to have separate object ast2 with separate data, not depending on changes made in ast1.
As I said deepCopy doesn't work. Any ideas?

Thanks,
Mark
Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Uko2
I’m not sure if this is a case, but there is deepCopy and veryDeepCopy, maybe you should take a look at that.

Uko

> On 05 Nov 2014, at 18:04, Mark Rizun <[hidden email]> wrote:
>
> Hi everyone,
>
> I want to get a deep copy of ast. But deepCopy doesn't work:)
> What I mean:
>
> | ast1 ast2 |
> ast1 := RBParser parseRewriteExpression: 'self'.
> ast2 := ast1 copy."or without copy"
> ast1 stop: 99.
> ast2 stop
>
> When evaluate this you get 99. I want it to be 4.
> So I want to have separate object ast2 with separate data, not depending on changes made in ast1.
> As I said deepCopy doesn't work. Any ideas?
>
> Thanks,
> Mark


Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Thierry Goubier
In reply to this post by Mark Rizun
Le 05/11/2014 18:04, Mark Rizun a écrit :

> Hi everyone,
>
> I want to get a deep copy of ast. But deepCopy doesn't work:)
> What I mean:
>
> | ast1 ast2 |
> ast1 := RBParser parseRewriteExpression: 'self'.
> ast2 := ast1 copy."or without copy"
> ast1 stop: 99.
> ast2 stop
>
> When evaluate this you get 99. I want it to be 4.
> So I want to have separate object ast2 with separate data, not depending
> on changes made in ast1.
> As I said deepCopy doesn't work. Any ideas?

I'd say beware. Deep copying ASTs is hard. You'll need to characterize a
bit better what has been copied with deepCopy and what hasn't before
starting to hack it.

Thierry

>
> Thanks,
> Mark


Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Mark Rizun
You see, when I alpply deepCopy instead of copy, pharo image doesn't respond:)
What I want is to get 100% independent new object ast2, with same caracteristics as ast1.
P.S. Uko, thanks veryDeepCopy works. Read the comments to both methods but still confused why deepCopy didn't work.
Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Mark Rizun
As I said, I used veryDeepCopy for copying ASTs, and it worked. But! It takes time to copy:)

2014-11-06 11:59 GMT+02:00 Mark Rizun <[hidden email]>:
You see, when I alpply deepCopy instead of copy, pharo image doesn't respond:)
What I want is to get 100% independent new object ast2, with same caracteristics as ast1.
P.S. Uko, thanks veryDeepCopy works. Read the comments to both methods but still confused why deepCopy didn't work.

Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Mark Rizun
Do you have any other suggestions how can I get completely indemendent copy of ast?

2014-11-06 12:19 GMT+02:00 Mark Rizun <[hidden email]>:
As I said, I used veryDeepCopy for copying ASTs, and it worked. But! It takes time to copy:)

2014-11-06 11:59 GMT+02:00 Mark Rizun <[hidden email]>:
You see, when I alpply deepCopy instead of copy, pharo image doesn't respond:)
What I want is to get 100% independent new object ast2, with same caracteristics as ast1.
P.S. Uko, thanks veryDeepCopy works. Read the comments to both methods but still confused why deepCopy didn't work.


Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Marcus Denker-4
Hello,

Normally #copy should copy the AST. But it might not copy all the things related to start/stop.

I think we should fix it to do that, too.

(sorry that I am a bit slow answering… lots of things to do)

On 06 Nov 2014, at 11:36, Mark Rizun <[hidden email]> wrote:

Do you have any other suggestions how can I get completely indemendent copy of ast?

2014-11-06 12:19 GMT+02:00 Mark Rizun <[hidden email]>:
As I said, I used veryDeepCopy for copying ASTs, and it worked. But! It takes time to copy:)

2014-11-06 11:59 GMT+02:00 Mark Rizun <[hidden email]>:
You see, when I alpply deepCopy instead of copy, pharo image doesn't respond:)
What I want is to get 100% independent new object ast2, with same caracteristics as ast1.
P.S. Uko, thanks veryDeepCopy works. Read the comments to both methods but still confused why deepCopy didn't work.



Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Mark Rizun
Normally #copy should copy the AST. But it might not copy all the things related to start/stop.

Yes #copy, copies not all stuff. That's why I need #deepCopy but it just crashes image. And #veryDeepCopy works veeeery slow.
I need another solution. Any suggestions? Maybe there is some kind of method that does what I want?
 

(sorry that I am a bit slow answering… lots of things to do)

It's fine;) 
Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Marcus Denker-4

On 06 Nov 2014, at 16:24, Mark Rizun <[hidden email]> wrote:

Normally #copy should copy the AST. But it might not copy all the things related to start/stop.

Yes #copy, copies not all stuff. That's why I need #deepCopy but it just crashes image. And #veryDeepCopy works veeeery slow.
I need another solution. Any suggestions? Maybe there is some kind of method that does what I want?
 
Why not fix #copy to copy the things needed?

have a look at the #postCopy methods.

Marcus
Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Mark Rizun
If I understand #postCopy is used to override standart copy. Each class has(or may have) its own implementation of #postCopy.
When #copy is applied, #postCopy is called.

2014-11-06 17:47 GMT+02:00 Marcus Denker <[hidden email]>:

On 06 Nov 2014, at 16:24, Mark Rizun <[hidden email]> wrote:

Normally #copy should copy the AST. But it might not copy all the things related to start/stop.

Yes #copy, copies not all stuff. That's why I need #deepCopy but it just crashes image. And #veryDeepCopy works veeeery slow.
I need another solution. Any suggestions? Maybe there is some kind of method that does what I want?
 
Why not fix #copy to copy the things needed?

have a look at the #postCopy methods.

Marcus

Reply | Threaded
Open this post in threaded view
|

Re: [Oharo-users] Copy AST

Mark Rizun
P.S. I must have thought about fixing copy:) Don't know why I didn't

2014-11-06 17:54 GMT+02:00 Mark Rizun <[hidden email]>:
If I understand #postCopy is used to override standart copy. Each class has(or may have) its own implementation of #postCopy.
When #copy is applied, #postCopy is called.

2014-11-06 17:47 GMT+02:00 Marcus Denker <[hidden email]>:

On 06 Nov 2014, at 16:24, Mark Rizun <[hidden email]> wrote:

Normally #copy should copy the AST. But it might not copy all the things related to start/stop.

Yes #copy, copies not all stuff. That's why I need #deepCopy but it just crashes image. And #veryDeepCopy works veeeery slow.
I need another solution. Any suggestions? Maybe there is some kind of method that does what I want?
 
Why not fix #copy to copy the things needed?

have a look at the #postCopy methods.

Marcus