Live data from Hacker News

Ruby, Smalltalk and Class Variables

patshaughnessy.net

11–15 of 15 posts

Re: Ruby, Smalltalk and Class Variables

#11

This is one of the areas that prototype-based languages simplifies although access issues might trouble class lovers. I do miss NewtonScript for some things. Example: I create an object called Polygon with the intent to use it as a prototype. I assign the variable sides with a value of 10. So, anything with a parent pointer of Polygon gets 10. I then create Triangle from Polygon and assign sides = 3. It doesn't affec…

Making that simple is not necessarily limited to prototype-based languages. Another (as good as) dead language of Apple's design, Dylan, is class-based, but has a 'each-subclass' modifier that makes a slot magically appear new in each subclass. You would have to design your polygon class for that, though; it is not something that triangle could magically add.

Re: Ruby, Smalltalk and Class Variables

#12
In Kay's Smalltalk, humans never saw code like that in the article: they defined classes, variables and methods through a graphical interface. The verbose syntax was for computers to read, when you saved code on one machine and loaded it on another. Humans only had to write this stuff after Gnu released a text-only interpreter; the subset of Smalltalk syntax that was originally intended for human use is pretty clear.

Re: Ruby, Smalltalk and Class Variables

#13
post #11

This is one of the areas that prototype-based languages simplifies although access issues might trouble class lovers. I do miss NewtonScript for some things. Example: I create an object called Polygon with the intent to use it as a prototype. I assign the variable sides with a value of 10. So, anything with a parent pointer of Polygon gets 10. I then create Triangle from Polygon and assign sides = 3. It doesn't affec…

Making that simple is not necessarily limited to prototype-based languages. Another (as good as) dead language of Apple's design, Dylan, is class-based, but has a 'each-subclass' modifier that makes a slot magically appear new in each subclass. You would have to design your polygon class for that, though; it is not something that triangle could magically add.

It is too bad someone hasn't gone back a released a retooled, s-expr version of Dylan. It was an interesting language. People should read the manual (infix) just to see how they did macros.

Re: Ruby, Smalltalk and Class Variables

#14
In the Perl/Moose world, class variables (attributes) are regarded as a broken concept: http://www.perlmonks.org/?node_id=690482

ref: stvn == "Stevan Little" who is the creator of Moose (https://metacpan.org/module/Moose) & and it's MOP underpinnings (https://metacpan.org/module/Class::MOP)

Re: Ruby, Smalltalk and Class Variables

#15

This is one of the areas that prototype-based languages simplifies although access issues might trouble class lovers. I do miss NewtonScript for some things. Example: I create an object called Polygon with the intent to use it as a prototype. I assign the variable sides with a value of 10. So, anything with a parent pointer of Polygon gets 10. I then create Triangle from Polygon and assign sides = 3. It doesn't affec…

Io (http://iolanguage.org/) shares the same differential inheritance has NewtonScript:

  Polygon  := Object clone do( sides := 10 )
  Triangle := Polygon clone
  
  Triangle sides println    # => 10
  Triangle sides := 3
  Triangle sides println    # => 3
  Polygon sides println     # => 10
Post reply on HN