TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ruby, Smalltalk and Class Variables

35 pointsby lestover 12 years ago

6 comments

gwrightover 12 years ago
Towards the end of this article there is a reference to the 'metaclasss'. It should probably be noted that the prefered terminology in the Ruby community now is 'singleton class' and not 'metaclass'.<p>For quite a while there was little agreement on this name because there was no standard method that could be called to return the singleton class and therefore no agreed upon name. The only access was via syntax:<p><pre><code> (class &#60;&#60;object; self; end) </code></pre> The results of this expression were called metaclass, eigenclass, singleton class, and probably a few more names.<p>There is now a standard method:<p><pre><code> object.singleton_class </code></pre> and so, for the most part, the naming confusion is fading away.
评论 #4933327 未加载
protomythover 12 years ago
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.<p>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 affect Polygon (which has its own variable), but anything that has a parent pointer of Triangles get the 3.
评论 #4936702 未加载
评论 #4934667 未加载
endlessvoid94over 12 years ago
I'd never read the linked Alan Kay paper about the development of Smalltalk [1]. It's fascinating!<p>I've been trying for awhile to find readings or videos (or anything, really) about those early days at ARPA and then PARC. Especially the detailed discussion of the smalltalk development. The names and stories are also pretty neat to read, and have already inspired a few ideas personally.<p>[1] <a href="http://www.smalltalk.org/smalltalk/TheEarlyHistoryOfSmalltalk_Abstract.html" rel="nofollow">http://www.smalltalk.org/smalltalk/TheEarlyHistoryOfSmalltal...</a>
评论 #4934192 未加载
why-elover 12 years ago
This was also discussed five years ago in this great post by Martin Fowler: <a href="http://martinfowler.com/bliki/ClassInstanceVariable.html" rel="nofollow">http://martinfowler.com/bliki/ClassInstanceVariable.html</a>
评论 #4933008 未加载
draegtunover 12 years ago
In the Perl/Moose world, class variables (attributes) are regarded as <i>a broken concept</i>: <a href="http://www.perlmonks.org/?node_id=690482" rel="nofollow">http://www.perlmonks.org/?node_id=690482</a><p>ref: <i>stvn</i> == "Stevan Little" who is the creator of Moose (<a href="https://metacpan.org/module/Moose" rel="nofollow">https://metacpan.org/module/Moose</a>) &#38; and it's MOP underpinnings (<a href="https://metacpan.org/module/Class::MOP" rel="nofollow">https://metacpan.org/module/Class::MOP</a>)
thisrodover 12 years ago
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.