Update page 'Future AerScript Versions'
@@ -2,7 +2,6 @@
|
||||
This document describes an ideas for future versions of __Aer__ language specification
|
||||
|
||||
* Namespace support
|
||||
* Operator overloading
|
||||
* Transient fields
|
||||
* 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
|
||||
|
||||
### 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 {
|
||||
public float $breadth;
|
||||
public float $height;
|
||||
public float $length;
|
||||
|
||||
operator +(Box $box1, Box $box2) {
|
||||
object operator+(Box $box1, Box $box2) {
|
||||
object $box = new Box();
|
||||
$box->breadth = $box1->breadth + $box2->breadth;
|
||||
$box->height = $box1->height + $box2->height;
|
||||
|
||||
Reference in New Issue
Block a user