If we can get rid off the myriad of class creation methods count me in. :) I would do something like:
ClassBuilder new name: #A; superclass: Object; addInstanceVariableNamed: 'a'; addInstanceVariableNamed: 'c'; addBooleanSlotNamed: 'z'; addClassVariableNamed: 'D'; use: SomeTrait; use: SomeOtherTrait; beWeak "if you want a weak subclass"; build With all of this optional. If we can avoid to pass nil as superclass for the cases you don't have a superclass that would be good, maybe an specific method in the builder ? On Mon, May 22, 2017 at 4:25 AM, Luc Fabresse <[email protected]> wrote: > 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 >
