Path: utzoo!utgpu!jarvis.csri.toronto.edu!daemon Newsgroups: comp.lang.smalltalk From: thomson@hub.toronto.edu (Brian Thomson) Subject: Re: Smalltalk syntax question/quibble Message-ID: <9003071536.AA17270@beaches.hub.toronto.edu> Sender: Organization: University of Toronto References: <147@cnam.UUCP> Date: 7 Mar 90 15:39:32 GMT Lines: 32 In article peter@ficc.uu.net (Peter da Silva) writes: >I have thought that the Smalltalk syntax for defining a new class was >a bit inconsistent with the rest of the language. > ... > Point <- Magnitude Subclass: #( 'x' 'y' ). > Point Method: 'new' Is: [ x <- 0. y <- 0. ^self. ]. > Point Method: 'x:y:' Is: [ x0 y0 | x <- x0. y <- y0. ]. > Integer Method: '@' Is: [ y | > p <- Point new. > p x: self y: y. > ^p. > ]. > For starters, those method bodies are compiled in the immediate execution environment. You have to pass a string, not a block, so the compiler can compile them in the context of the newly created class. Other than that, this doesn't seem to be a very great departure. You are doing more or less what Smalltalk already does, except that you are ignoring (and, I presume, defaulting) a lot of other information that Smalltalk lets you provide, eg.: Subclass: variables ^self subclass: (Symbol new: 0) "Subclass name not known" instanceVariableNames: variables classVariableNames: nil poolDictionaries: nil category: 'NoCategory'. -- Brian Thomson, CSRI Univ. of Toronto utcsri!uthub!thomson, thomson@hub.toronto.edu