In this document we present the basic data types defined in Clump.
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(); }
package clump.lang interface byte extends Equivalent<byte>, View { char toChar(); }
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.
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.
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 final int extends Numerical<int,int> { // Bit wise operators int (|)(int); int (&)(int); int (^)(int); // Conversions long toLong(); float toFloat(); }
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(); }
package clump.lang interface float extends Numerical<float,float> { int toInt(); long toLong(); }
package clump.lang interface double extends Numerical<double,double> { int toInt(); long toLong(); }