Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value. Is there a way to know if a class is passed by reference or by value? Only small integers are passed as value? Thanks in advance Nacho ----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Hi, Most classes are passed by reference including those that were defined by user. But classes like integer are passed by value. I think it's similar to C#. I may be wrong, so better wait for another more competent reply:) Best, Mark 2014-09-25 21:14 GMT+03:00 nacho <0800nacho@gmail.com>:
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value. Is there a way to know if a class is passed by reference or by value? Only small integers are passed as value? Thanks in advance Nacho
----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
2014-09-25 15:14 GMT-03:00 nacho <0800nacho@gmail.com>:
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value. Is there a way to know if a class is passed by reference or by value?
Only small integers are passed as value?
Yes. It has to do with the object headers, SmallIntegers are embedded in the OH. Esteban A. Maringolo
Floats are passed as values. Objects that are passed as values should be immutable, as floats and integers. Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. On Sep 25, 2014, at 3:35 PM, Mark Rizun <mrizun@gmail.com> wrote:
Only small integers are passed as value?
Yes.
It has to do with the object headers, SmallIntegers are embedded in the OH.
What about Float, for example?
I forgot. Floats too. And I think that's it. Esteban A. Maringolo 2014-09-25 15:35 GMT-03:00 Mark Rizun <mrizun@gmail.com>:
Only small integers are passed as value?
Yes.
It has to do with the object headers, SmallIntegers are embedded in the OH.
What about Float, for example?
On 25 Sep 2014, at 20:28, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
2014-09-25 15:14 GMT-03:00 nacho <0800nacho@gmail.com>:
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value. Is there a way to know if a class is passed by reference or by value?
Only small integers are passed as value?
Yes.
It has to do with the object headers, SmallIntegers are embedded in the OH.
In the *reference*, not the header. The reference points to a header for a normal object, for small-integers the reference *is* the integer value. This means that there is no header for the integers. Marcus
On 26 Sep 2014, at 8:24 , Marcus Denker <marcus.denker@inria.fr> wrote:
On 25 Sep 2014, at 20:28, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
2014-09-25 15:14 GMT-03:00 nacho <0800nacho@gmail.com>:
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value. Is there a way to know if a class is passed by reference or by value?
Only small integers are passed as value?
Yes.
It has to do with the object headers, SmallIntegers are embedded in the OH.
In the *reference*, not the header. The reference points to a header for a normal object, for small-integers the reference *is* the integer value. This means that there is no header for the integers.
Marcus
So, a succinct phrasing indifferent to object format, using a relatively well-defined term, would be: Only immediate objects are passed by value. (Which means you have to explain immediate objects, as markus did) Cheers, Henry
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value.
Strange I do not remember having written that. Especially because in Smalltalk this has no real interest.
Is there a way to know if a class is passed by reference or by value? In Smalltalk consider that everything is an object and that you pass a reference to the object. Only small integers are passed as value? Thanks in advance Nacho
----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
" stepharo wrote
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value.
Strange I do not remember having written that. Especially because in Smalltalk this has no real interest.
Well you also wrote that :p
"Deep in the implementation of Smalltalk, there are three different kinds of objects. There are (1) ordinary objects with instance variables that are passed by references, there are (2) small integers that are passed by value, and there are (3) indexable objects like arrays that hold a contiguous portion of memory. The beauty of Smalltalk is that you normally donât need to care about the differences between these three kinds of object.
Is there a way to know if a class is passed by reference or by value? In Smalltalk consider that everything is an object and that you pass a reference to the object. Only small integers are passed as value? Thanks in advance Nacho
----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289p4780321.ht... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Depending on the VM you use, different objects are passed by values. Currently -> only smallintegers on Spur 32 bits VM -> smallintegers and characters on Spur 64 bits VM -> smallintegers, characters and smallfloat But as Stef said it does not really matter in smalltalk. 2014-09-25 21:55 GMT+02:00 nacho <0800nacho@gmail.com>:
" stepharo wrote
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value.
Strange I do not remember having written that. Especially because in Smalltalk this has no real interest.
Well you also wrote that :p
"Deep in the implementation of Smalltalk, there are three different kinds of objects. There are (1) ordinary objects with instance variables that are passed by references, there are (2) small integers that are passed by value, and there are (3) indexable objects like arrays that hold a contiguous portion of memory. The beauty of Smalltalk is that you normally donât need to care about the differences between these three kinds of object.
Is there a way to know if a class is passed by reference or by value? In Smalltalk consider that everything is an object and that you pass a reference to the object. Only small integers are passed as value? Thanks in advance Nacho
----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289p4780321.ht... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
On 26 Sep 2014, at 08:07, Clément Bera <bera.clement@gmail.com> wrote:
Depending on the VM you use, different objects are passed by values.
Currently -> only smallintegers on Spur 32 bits VM -> smallintegers and characters on Spur 64 bits VM -> smallintegers, characters and smallfloat
But as Stef said it does not really matter in smalltalk.
Yes, even for these cases you pass the *reference*, only that the reference happens to encode the value. Marcus
Indeed, one should not care about copy by value / reference in Pharo. Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. On Sep 25, 2014, at 4:52 PM, stepharo <stepharo@free.fr> wrote:
Hi, In PBE says that ordinary objects' ivars are passed by references and small integers are passed by value.
Strange I do not remember having written that. Especially because in Smalltalk this has no real interest.
Is there a way to know if a class is passed by reference or by value? In Smalltalk consider that everything is an object and that you pass a reference to the object. Only small integers are passed as value? Thanks in advance Nacho
----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Passed-by-references-and-by-value-tp4780289.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
participants (8)
-
Alexandre Bergel -
Clément Bera -
Esteban A. Maringolo -
Henrik Johansen -
Marcus Denker -
Mark Rizun -
nacho -
stepharo