Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why instanceVariableNames is a String and not a more structured collection

I'm a Smalltalk beginner, currently playing with Pharo and I'm curious about a choice in the subclass message: the keyword instanceVariableNames wants something able to answer to the subStrings message. I wonder why it doesn't expect something more structured like an array, since what is needed is a collection of symbols.

Object subclass: #Experiment instanceVariableNames: #(#foo #bar).

My only guessing at this is some historical reason: maybe not all Smalltalks have arrays or their syntax differs to much to slip into an inner message as subclass. Is there any other explanation?

like image 306
eMMe Avatar asked Mar 25 '13 06:03

eMMe


People also ask

Are string objects in a pool immutable?

The String objects are cached in the String pool, and it makes the String immutable. The cached String literals are accessed by multiple clients. So, there is always a risk, where action performs by one client affects all other clients.

Can a generic Java collection store primitive data types?

Since the above two statements are true, generic Java collections can not store primitive types directly. Wrapper Class provides a way to use primitive data types (int, boolean, etc..) as objects or a Wrapper class is a class whose object wraps or contains primitive data types.

Why string is immutable in Java?

The String is immutable in Java because of the security, synchronization and concurrency, caching, and class loading. The reason of making string final is to destroy the immutability and to not allow others to extend it.

Why can't I assign a value to a string object?

Now, since String s are immutable, the VM can’t assign this value to str, so it creates a new String object, gives it a value "knowledge base", and gives it a reference str. An important point to note here is that, while the String object is immutable, its reference variable is not.


1 Answers

In the Pharo vision document, one of the points is to change that and have a real notion of instance variables. Check these links if you are interested:

  • http://scg.unibe.ch/archive/papers/Verw11bFlexibleObjectLayouts.pdf
  • http://www.pharo-project.org/download/pictures/be/j32hajf3kjdbsebqo0a9zc5tk8ekxt/pharovision.pdf
like image 160
Damien Cassou Avatar answered Sep 22 '22 23:09

Damien Cassou