` Janic Operator Declarations

 

The Janic compiler breaks the Math, Boolean, Conditional, Branch, Search, Retrieval, and Assignment operations into individual operator systems based on Data Type. The operator statement in emulation mode acts as an in-line function, and in compile mode acts as an assembler template.

The statements in the Operator statement group are treated differently than other statements. A program statement of B = A + 1; will call upon the operator statement return Operand[0] + Operand[1]; which is executed as a hardware instruction. The two statements may look identical but are treated differently. There is no restrictions on the use on the type of statements in an operator statement group, however it is not a function but rather the statements act (somewhat) as part of the active function.


The Operator Statement

operator (type_operand_left, opcode, type_operand_right) { ... }

operator (type_operand, opcode) { ... }

operator (opcode, type_operand) { ... }


Two Operator Opcodes

+ - * ** / // >> << >>> < > <= >= == != | || & && = ^ % += -= /= **= <<= >>= >>>=

One Operator Opcodes

+ - ++ -- {} () []

foreign Opcodes

any-text(precedence like known-opcode)
 


Known Operand Types

Integer, Counting Number, Whole Number, Real, Complex, Date, Time, DateTime, Array, Matrix, Table, Object, RegExp, Fraction, Rational Number

Programmed Operand Types

function-name (i.e. function Person() { }; A = new Person(); )

Wildcard Operand Types

* any number of characters, % any single character (i.e. * = integer )

Foreign Operand Types

opcode(known opcode or function name)  opcode is not a known opcode or a function name which is treated as the opcode in parentheses,  (i.e. cross(+) "cross" is not known but acts as if it were a plus sign "+", having the same precedence and is left ordered.


 

Examples

operator (integer, +, integer) {factor_addition(uA,uB)(f,units); return (A + (B*f)) as units;}

operator (integer, *, integer) {factor_multiply(uA,uB)(f,units); return (A * (B*f)) as units;}

operator (integer, +=, integer) { return this + A }; A += 10;

operator (integer, []) { return Integer Of Selected Bits(arguments) };  B = A[1-5];

operator (matrix, dot(+), matrix) { ... }  D = A dot (B dot C);