Hi,

Following Pharo Days, I brainstormed about some possible class definition
syntaxes.
What I have in mind:

"basic mechanics, only THIS one in the image!"
ClassDefinition new
superclass: Object; "optional. If not specified, Object by default ;-)"
name: #A; "optional and create an anonymous class if not specified"
instVars: 'a b c';
traits: {TEquality};
package: 'Plop';
createClass. " this message sent might be hidden by the browser when
accepting"

"---------------"
"Some IDEAS (but I did not find one that I really like) of
scripting/shorter syntaxes that must ALWAYS end up calling the above basic
mechanics at the end:"

Class fromDefinition: [ :def |
def name: #sub;
instVars: 'w r g';
superclass: Object ].

Object subclass  "<-- returns a subclass of Object but the problem is that
the new class is muted each time and the class definition is not explicit"
name: #A;
ivs: 'a b c';
traits: { TEquality }.

{ #superclass -> Object.
#name -> #sub.
#instVars -> 'a b c' } asClass.

{ Object asSuperclass.
 #sub asClassName.
'a b c' asInstVars.
'c' asClassVar } asClass.

"litteral approach"
#( name A
superclass Object
instVars #(a b c)
instVar d
) asClass


#Luc

Reply via email to