|
| <prev next> |
Re: >> notation: msg#00190lang.smalltalk.squeak.beginners
In the example: In Smalltalk, classes aren't defined with a text definition like a file-based language. Instead, a message is sent to a superclass asking it to create a subclass (1). Then methods are individually entered in the Browser, which sends messages to compile and add the method (2). So there is no simple text syntax that "is" the class/method. This is a problem if I want to show it to someone on a mailing list, or if I want to duplicate the class in another image. In any other language I would just copy and paste it from the source file with syntax intact. Thus there is a convention that when you talk about method foo in class FooClass, you refer to it as "FooClass>>foo". I think the convention is also used in the changeset file format used to move code around. Further, I am confused that the ">>" is not a symbol that is input to It is not Smalltalk code, just a notation used by programmers and import/export tools to describe where the code should be. Last, I do not understand how the MyClass>>doThis of the above It simply says "method doThis in class MyClass is where this code comes from (or goes)". happy squeaking! Joe Koberg joe at osoft dot us 1. The class creation message looks like this: Object subclass: #FooClass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Test Classes' 2. When the typed-in method body is "accepted", the browser sends messages vaugely like the following to create the method: "in this example the methodText is hardcoded" methodText := ' squareFoo: argument |a| a := argument. ^ a * a. '. parsedMethod := (Compiler new) compile: methodText in: FooClass notifying: nil ifFail: nil. rawMethod := parsedMethod generate. FooClass addSelector: #squareFoo: withMethod: rawMethod
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: >> notation, Emilio Oca |
|---|---|
| Previous by Thread: | Re: >> notation, Another Dave |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |