Update page 'Future AerScript Versions'
@@ -2,7 +2,6 @@
|
|||||||
This document describes an ideas for future versions of __Aer__ language specification
|
This document describes an ideas for future versions of __Aer__ language specification
|
||||||
|
|
||||||
* Namespace support
|
* Namespace support
|
||||||
* Operator overloading
|
|
||||||
* Transient fields
|
* Transient fields
|
||||||
* Variadic methods
|
* Variadic methods
|
||||||
|
|
||||||
@@ -14,13 +13,14 @@ A right associative \** operator can be added to support exponentiation, along w
|
|||||||
printf("2 ** 3 ** 2 = %d\n", 2 ** 3 ** 2); // 512
|
printf("2 ** 3 ** 2 = %d\n", 2 ** 3 ** 2); // 512
|
||||||
|
|
||||||
### Operator overloading
|
### Operator overloading
|
||||||
|
It should be possible to redeclare or overload most of the built-in operators available in AerScript. Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. similar to any other function, an overloaded operator has a return type and a parameter list.
|
||||||
|
|
||||||
class Box {
|
class Box {
|
||||||
public float $breadth;
|
public float $breadth;
|
||||||
public float $height;
|
public float $height;
|
||||||
public float $length;
|
public float $length;
|
||||||
|
|
||||||
operator +(Box $box1, Box $box2) {
|
object operator+(Box $box1, Box $box2) {
|
||||||
object $box = new Box();
|
object $box = new Box();
|
||||||
$box->breadth = $box1->breadth + $box2->breadth;
|
$box->breadth = $box1->breadth + $box2->breadth;
|
||||||
$box->height = $box1->height + $box2->height;
|
$box->height = $box1->height + $box2->height;
|
||||||
|
|||||||
Reference in New Issue
Block a user