Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!cronkite!exodus!sbb From: sbb@laplace.eng.sun.com (Steve Byrne) Newsgroups: comp.lang.smalltalk Subject: Re: GNU Smalltalk-1.1 problems Message-ID: Date: 21 Jun 91 02:00:08 GMT References: Sender: news@exodus.Eng.Sun.COM Distribution: comp.lang.smalltalk Organization: FSF hackers, Smalltalk division Lines: 87 In-reply-to: peters@sirius.UVic.CA's message of 19 Jun 91 17:44:19 GMT In article peters@sirius.UVic.CA (Doug Peters) writes: From: peters@sirius.UVic.CA (Doug Peters) Newsgroups: comp.lang.smalltalk Date: 19 Jun 91 17:44:19 GMT Granted, I am almost a novice at Smalltalk, but I thought that I was asking GNU Smalltalk-1.1 to do some pretty basic things... For example, I have a Complex class (I chose to make this a subclass of Number because I wanted "isKindOf: Number" to still work) So I have a file called "Complex.st", which looks like: "------------------------------------------------>8" Number variableSubclass: #Complex instanceVariableNames: 're im ' classVariableNames: '' poolDictionaries: '' category: ''! !Complex methodsFor:'accessing'! re: aNumber im: anotherNumber re := aNumber. im := anotherNumber! ! !Complex class methodsFor: 'instance creation'! re:aNumber im:anotherNumber "<- this is line 15" | a | a := super new. a re:aNumber im:anotherNumber. "<- this is line 18" ^a! ! "------------------------------------------------>8" st> FileStream fileIn:'Complex.st' ! produces: "Complex.st", line 15: parse error "Complex.st", line 15: Invalid message pattern "Complex.st", line 18: Error in expression "Complex.st", line 18: parse error "Complex.st", line 18: Invalid message pattern "Complex.st", line 19: Error in expression The problem here is that GNU Smalltalk's lexer is greedy: it really thinks that if it's seen "foo:bar" that it's processing a keyword symbol and is expecting to see a colon following it. Unfortunately, there is no colon at the end, so it yells. You can argue with whether this is the right behavior or not; I think the Blue Book indicated that this was the way things were, but it could probably be a little smarter in the future (like, say the 2.0 timeframe when the compiler code is written in Smalltalk). In this case, if you just put a space between the keyword and the argument name, you should win. st> ArrayedCollection variableSubclass: #Matrix st> instanceVariableNames: 'nrow ncol ' st> classVariableNames: '' st> poolDictionaries: '' st> category: ''! and I get: ArrayedCollection error: cannot create a variable subclass from a non-pointer variable parent class I've changed things related to this in 1.2. The basic problem is that isWords and isBytes are lying: isWords should only return true if it's not pointers AND is has the proper bit set. isBytes should not be a pointer and should not be words. These two methods are used by variableSubclass for error detection, although the way they are implemented now, they're more involved with error creation :-) Change the definitions in Behavior.st of isWords and isBytes thus: isBytes ^self isPointers not & self isWords not ! isWords ^self isPointers not & ((self instanceSpec bitAt: 29) ~= 0) ! And you'll win. Steve