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
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 <mrizun@gmail.com> 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
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
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.
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 <mrizun@gmail.com>:
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.
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 <mrizun@gmail.com>:
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 <mrizun@gmail.com>:
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.
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 <mrizun@gmail.com> 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 <mrizun@gmail.com <mailto:mrizun@gmail.com>>: 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 <mrizun@gmail.com <mailto:mrizun@gmail.com>>: 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.
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;)
On 06 Nov 2014, at 16:24, Mark Rizun <mrizun@gmail.com> 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
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 <marcus.denker@inria.fr>:
On 06 Nov 2014, at 16:24, Mark Rizun <mrizun@gmail.com> 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
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 <mrizun@gmail.com>:
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 <marcus.denker@inria.fr>:
On 06 Nov 2014, at 16:24, Mark Rizun <mrizun@gmail.com> 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
participants (4)
-
Marcus Denker -
Mark Rizun -
Thierry Goubier -
Yuriy Tymchuk