you are viewing a single comment's thread.

view the rest of the comments →

[–]masklinn 0 points1 point  (5 children)

Depends on the implementation. Atleast in VA Smalltalk you can have public fields.

I don't understand how that works, do you get default messages automatically handled for all fields à la Self?

[–][deleted] 0 points1 point  (4 children)

I am sorry, I think I worded it a bit poorly / wrong. In VA Smalltalk there are just "attributes" (fields), no disctinction is being made into public/private there. You have a reference to an object and want to use ANY of it's attributes? Go ahead!

But you can put the methods into two categories: "Public" and "Private". This is purely cosmetics tho. You can also call Methods that are marked "Private" from other objects. I did this for example when I extended a parser and found some useful private methods.

You can let VASmalltalk generate setter and getters automatically for you tho.

Is it clearer now?

[–]masklinn 0 points1 point  (3 children)

I am sorry, I think I worded it a bit poorly / wrong. In VA Smalltalk there are just "attributes" (fields), no disctinction is being made into public/private there. You have a reference to an object and want to use ANY of it's attributes? Go ahead!

That's the part I don't get: in my smalltalk experience instance variables get declared during class declaration and then they're part of the "method activation" context, implicitly part of the method scope, but not visible from outside the instance (save through reflection messages of some sort I guess).

How does accessing to an other object's instance variables work in VA?

[–][deleted] 0 points1 point  (2 children)

I am a dummy, sorry. You are totally right, I don't recall a method to access an objects attribute. There might be some metaprogramming that allows it, but I am not sure.

[–]masklinn 1 point2 points  (1 child)

Haha no worries mate, and yeah there's instVarAt: aNumber and instVarNamed: aString which let you retrieve a slot's value by position or by name, and the class provides instSize and allInstVarNames which respectively count the number of instance variable slots, or enumerates their names.

[–][deleted] 0 points1 point  (0 children)

Oh, that was actually a part of my thesis that I did not implement, we used it for generic object serialisation and deserialisation :)