You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes you have a bunch of small classes that don't justify all the trouble of writing class a hundred times. The same could be said for subclasses or a class full of static methods. Can coconut provide the option to use a meta/superclass' name instead of the class keyword?
draw more attention to the actual data structure being used, thus helping the developer think in terms of their own program's structure, rather than strictly thinking in terms of the Python/Coconut semantics
reduce repetitive keywords and improve code readability
be convenient
Besides writing generic superclass_name subclass_name: ... statements, other use-cases would be:
OOP keywords:
meta/metaclass: declares that a given class is a subclass of type
metaMakeSerializable: ...
# same asclassMakeSerializable (type): ...
abstract: declares that a given class is a subclass of abc.ABC
abstractMyAbstractClass: ...
# same asclassMyAbstractClass (abc.ABC): ...
static: annotates all methods in the given class as staticmethods
Decorators accomplish the same functionality, but they are not as concise, especially when you have to write hundreds of rules for your biochemistry simulator.
Directly specify the metaclass. Metaclasses are not as easy to read as when they are buried around subclasses and metaclass kwargs.
Write a domain specific language. DSL's sacrifice flexibility for speed and clarity. However if the recommended feature is accepted into coconut, developers can have both.
The text was updated successfully, but these errors were encountered:
Sometimes you have a bunch of small classes that don't justify all the trouble of writing
class
a hundred times. The same could be said for subclasses or a class full of static methods. Can coconut provide the option to use a meta/superclass' name instead of theclass
keyword?Such a feature would be used like so:
Custom keyword'ed blocks would:
Besides writing generic
superclass_name subclass_name: ...
statements, other use-cases would be:meta/metaclass
: declares that a given class is a subclass oftype
abstract
: declares that a given class is a subclass ofabc.ABC
static
: annotates all methods in the given class asstaticmethods
subclass
: makes the given class a subclass of its containing class; thesubclass
declaration must take place inside another class.private
: you get the idearule
blocks for reactive subgraph rewritingAlternatives:
The text was updated successfully, but these errors were encountered: