I like very much the idea!

Creating a class can be done in many different ways. The Factory design pattern 
should be applied here I think.
Something like ClassFactory

Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



> On May 22, 2017, at 3: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


Reply via email to