Use Scala syntax (and semantics) for class definitions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Freeode |
New
|
Medium
|
Unassigned |
Bug Description
the Scala programming language has a very nice syntax for class definitions. Use a similar syntax for Siml and also implement some of Scala's semantics for the constructor.
The Siml specific twist would be, that the code in the class body defines
the constructor "__new__", not the initialization function "__init__".
Classes that implement new numeric types need an expression that constructs and them at once. They need to additionally define the method "__init__". Similarly to Python, classes are callable (but at compile time), the built in "__call__" macro constructs and initializes the new object. (It really returns code that constructs and initializes the data members.)
Inheritance could eventually be introduced like in Scala with the keyword "extends".
Example:
{{{
class Point:
val x: Float
val y: Float
def __init__(xc: Float, yc: Float):
x = xc
y = yc
def toString():
return "Point(" + x + ", " + y + ")"
}}}
Changed in freeode: | |
milestone: | none → 0.4.1 |
description: | updated |
description: | updated |
Changed in freeode: | |
importance: | Undecided → Medium |