Use Scala syntax (and semantics) for class definitions

Bug #998691 reported by Eike on 2012-05-13
This bug affects 1 person
Affects Status Importance Assigned to Milestone

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".

    class Point:
        val x: Float
        val y: Float

        def __init__(xc: Float, yc: Float):
            x = xc
            y = yc

        def toString():
            return "Point(" + x + ", " + y + ")"


Eike (eike-welk) on 2012-05-13
Changed in freeode:
milestone: none → 0.4.1
Eike (eike-welk) on 2012-05-13
description: updated
description: updated
Changed in freeode:
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers