Release 0.3

Download » Changes »

This last version provides the following enhancements:

  • Default attribute value when specifying objects.

    object Point {    
        int x,y = 0;
    }
    
    In this example a fresh point is the origin.

  • Function as first class objects

    import clump.io
    
    class main(System) implements Main {
        start(args) {
            String textToPrint = "Hello, World!";
            void helloWorld(Printer stream) {
                stream.println(textToPrint);       
            }
            helloWorld(this.stdout());
        }
    }
    
    A function as first class object can be combined with default attribute value as illustrated in the next example.
    object Point {    
        int x,y = 0;
        void move(int dx, int dy) {
            this.x += dx;
            this.y += dy;
        }
    }
    
    In this last example move is a functional attribute an therefore it can be modified. Such modification can be avoid as usual using the final specification.

  • Protected methods versus public methods. A class now can embed methods specified in implemented interfaces. Such methods are public and then are accessible inside and outside the class. In opposite methods locally specified and implemented are available and accessible inside the class and its inheritors. Indeed applied type verifications are the same for both public and protected methods.

    interface IMath {
        int fact(int);
    }
    
    class math(void) implements IMath {
        int fact(int current, int result) {
            if (current == 0) {
                return result;
            } else {
                return fact(current-1, result*current);
            }
        }
    
        fact(i) {
            // i >= 0
            return fact(i,1);
        }
    }