Variable B belongs to Object A. How can B get the reference to object A? You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/df3e2c12-b7fa-461b-a517-fd151e02e29c%40googlegroups.com. |
Hi Sergei,
-- Assuming what you are calling object A is a class of your making, you need to add an instance variable to that class calling it whatever you like, say varA. The add setter and getter methods like varA and varA:, something like this:
This is very basic stuff, so maybe a book on Smalltalk would help. Sorry, I can'y think of one off the top of my head. Maybe someone else will post a recommendation. There are also examples in the VA Smalltalk help docs. Lou On Tuesday, March 31, 2020 at 1:33:26 PM UTC-4, Sergei Filler wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/333d9eb7-338c-4943-aaae-7e41891be7e9%40googlegroups.com. |
Administrator
|
In reply to this post by ipstools.project
Sorry, Sergei. I had meant to send this reply earlier today, but got distracted. On Tuesday, March 31, 2020 at 10:33:26 AM UTC-7, Sergei Filler wrote:
The short answer is "It cannot." A longer answer is for A to tell B that it is referenced by A. The true answer is that using the reflection capabilities of Smalltalk, you can find reference paths. My favourite tool for VA Smalltalk is/was called The Exorcist. I don't know how well it works under recent versions, but I expect it would be fine. Instantiations has been exceptionally careful about preserving their APIs. It might be available from VAST Goodies. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/8680a20d-20d7-4ed6-9a40-b14997a8254e%40googlegroups.com. |
In reply to this post by Louis LaBrunda
Hi Sergei,
-- Sorry, I read your question wrong, backwards. I read "How can B get the reference to object A?" to be "How can A get the reference to object B?". I'm a bit dyslectic and when I'm not careful, I do this kind of thing. Anyway, my answer if not much different. Object B can't know about A without being told about it one way or another. Some objects (most don't) have an instance variable called #parent, to identify this kind of relationship. Maybe looking at them will help. Lou On Tuesday, March 31, 2020 at 5:40:00 PM UTC-4, Louis LaBrunda wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/dcab910c-2004-452f-a25e-8da56e397746%40googlegroups.com. |
Hi Louis, Richard. Thanks for the answers. Now I will stop researching how to do the thing in the topic :)) Just a continuation: can I get the list of instances of a class if I know the name of that class? You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/01b7161c-c3cf-4bc4-a6c1-baca58e93064%40googlegroups.com. |
Yes, see https://www.instantiations.com/docs/92/wwhelp/wwhimpl/js/html/wwhelp.htm#href=pr/stpr93.html
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/6f4a4393-6d34-4d65-936f-07d2bc2d95a1%40googlegroups.com. |
In reply to this post by ipstools.project
Am Dienstag, 31. März 2020 19:33:26 UTC+2 schrieb Sergei Filler:
--
It's probably best if you start by stating the actual problem that you're trying to solve, and what your level of experience with Smalltalk is. You might get more helpful answers than if people need to guess those things. In general, Smalltalk does not have a concept of "ownership", only references. So if an object A has a reference to an object B, it does not own it, there may be other objects who also have a reference. If you're talking about variables, those are the places where references to objects are held, but they are not objects in themselves (with the exception of shared variables which are basically a level of indirection). That said, there are methods by which you can find which objects point to a given object. These can be used do debug situations in which an object still exists although you thought it should have been garbage collected, but they are not to be used in application code. If your application requires an object to know who references it, add an explicit instance variable. For example, if you're building a tree data structure consisting of nodes, a common pattern in Smalltalk is to have instance variables "children" and "parent" which are maintained to stay in sync, so that each node in a tree knows its own children and its parent. Cheers, Hans-Martin You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/3d767d26-e5e8-428a-9f21-1e3b79e9175e%40googlegroups.com. |
In reply to this post by Wayne Johnston
Great post, Wayne :-)
-- среда, 1 апреля 2020 г., 17:37:47 UTC+3 пользователь Wayne Johnston написал:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/88873f30-3e50-4fc2-a32c-7d338eb9f24a%40googlegroups.com. |
Free forum by Nabble | Edit this page |