-
-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Pharo class definition Syntax #4671
Comments
Hi @Ducasse . Using superclass as receiver does not cover the case when it is nil. Currently for proxy kind objects we are forced to write two lines definition: Object subclass: MyProxy
...
MyProxy superclass: nil It does not looks right. Did you discuss in team my idea to use Class as receiver?
The minimal definition in that case is
Where superclass is Object by default |
Maybe we can use a block an evaluate it later with a [:class |
class
name: #MyObject;
superclass: Superclass;
uses: #MyTrait;
slots: { #a. #b };
classVariables: { #A. #B };
tags: #(Core) ;
package: #MyPackage
] For proxies just omit the |
Denis Now I will define the parser and produce the same model than the default one and we can play with variation. |
Gabriel |
Why not then something like Superclass subclassBuilder
name: #MyObject;
uses: #MyTrait;
slots: { #a. #b };
classVariables: { #A. #B };
tags: #(Core) ;
package: #MyPackage |
(#MyObject asClass)
superClass: SuperclassOrNil)
uses: #MyTrait;
slots: { #a. #b };
classVariables: { #A. #B };
tags: #(Core) ;
package: #MyPackage would be more message and object-oriented and works with the nil superclass if the #superclass message is left out or gives nil as argument. It also can be extended later with different environments than the default one: (#MyObject asClassInEnvironment: someEnvironment)
... |
Because we wantt to have a simple syntax that we can type in a texteditor so no extra parentheses (T. asClass is not good because it presumes that there is only one env), gabriel |
I see the Ruby class definitions. It's similar to other languages, specific syntactic constructs. I will certainly don't introduce new syntactic elements, just message sending (as this issue already proposes since the beginning). I find the Ruby syntax more cryptic than proper names, If we want that each class could provide a different subclass builder then we will need the message send (just we need to find a good name). Also I would change the slot definition syntax. Instead of having to provide an Array with some complex syntax rules, why not simple methods on the builder tailored for each slot kind?
and so on If you can explain us a little the context and motivations for changing the syntax of class creation we can have a more productive discussion :) . I'm really happy that we will get rid of this exponential combination of subclass creation messages and replace it with a proper builder (and remove the ones in |
Hi, this is great news, thanks to pushing this @Ducasse . I don't understand the motivation behind a compact class definition. Why do we need a compact one? I find ruby class definition economic in terms of amount of typed chars but quite obscure, not intelligible. I like the idea proposed by @gcotelli of using a unary message since I don't have to even think in a class name if I want an anonymous one. Not sure if |
I would also like a syntax like the one proposed by @gcotelli |
My first thought: is the superclass really good place for such hook? In my approach (with Class as receiver of definition syntax) the hook can be defined on the meta level. The class with special definition can be simply based on special kind of Class. So the special class will require special meta object: MyTypeOfClass <<< #MyNewSpecialClass
superclass: Object;
mySpecialProperty: '';
package: #MyPackage |
I agree with 'traits:' vs 'uses:' |
This can be closed as Fluid is now in (still needs more work, though) |
The new syntax for class definition (just for the class and not for the methods) is (modulo changes based on feedback)
Superclass <<< #MyObject
uses: #MyTrait;
slots: { #a. #b };
classVariables: { #A. #B };
tags: #(Core) ;
package: #MyPackage
The minimal class definition is the following one:
Superclass <<< #MyObject
package: #MyPackage
Note that sending a message to the superclass is close to subclass: and it lets the class selects
a class definition parser if the syntax should be extended.
In addition having a binary message makes () unneccessary.
The text was updated successfully, but these errors were encountered: