Clump Data Types

In this document we present the basic data types defined in Clump.

Interface for array
interface Array<E> extends Iterable<E> {
    int size();
    E getAt(int) throws IndexOutOfBoundException;
    E[] subContent(int, int) throws IndexOutOfBoundException;
    void setAt(int,E) throws IndexOutOfBoundException;
    E[] clone();
    E[] immutable();
}

Interface for byte data
package clump.lang

interface byte extends Equivalent<byte>, View {
    char toChar();
}

Interface for character data
package clump.lang

interface char extends Equivalent<char>, View {
    byte toByte();
}

A String is an array of characters. Then such data can be manipulated as an array but in addition string specific methods are also provided like the comparison operator and bytes externalisation used for stream based communication.

Interface for String data
package clump.lang

interface final String extends Array<char>, Equivalent<String>, View {
    String (+)(String);
    int parseInt() throws NumberFormatException;
    byte[] getBytes();
    boolean (==)(String);
    boolean (!=)(String);
}
class stringPrinter(System) implements Main {
    start(args) {
        for(char c: "Hello, World !") {
            this.stdout().print("[" + c + "]");
        }
        this.stdout().println();
    }
}
shalla-bal:clump $
./bin/clump stringPrinter -l site/bin [H][e][l][l][o][,][ ][w][o][r][l][d][!]
shalla-bal:clump $

All numericals are built on top of the same interface. In Clump like pure object oriented languages everything is an entity which can be an object or a denoted object by a class. In such approach a numberical is a denoted native object with a set of behaviors.

Interface for all numericals data covering integer, long, floats.
package clump.lang

import clump.util

interface Numerical<B,A extends B> extends Comparable<B>, Iterable<A>, View {
    A random();

    // Modulo
    A (%)(B);

    // Arithmetic operators
    A (+)(B);
    A (-)(B);
    A (*)(B);
    A (/)(B);
}
From this basic interface all Clump numericals are declined like integer, long, float and double.

Interface for integer data
interface final int extends Numerical<int,int> {
    // Bit wise operators
    int (|)(int);
    int (&)(int);
    int (^)(int);

    // Conversions
    long toLong();
    float toFloat();
}

Interface for long data
package clump.lang

type longOrInt = long | int

interface long extends Numerical<longOrInt, long> {
    // bitwise operators
    long (|)(longOrInt);
    long (&)(longOrInt);
    long (^)(longOrInt);

    // Conversions
    int toInt();
    float toFloat();
}

Interface for float data
package clump.lang

interface float extends Numerical<float,float> {
    int toInt();
    long toLong();
}

Interface for double data
package clump.lang

interface double extends Numerical<double,double> {
    int toInt();
    long toLong();
}