parent
f542ca2e41
commit
4e3522c400
@ -12,44 +12,6 @@ A right associative \** operator can be added to support exponentiation, along w
|
||||
printf("2 ** 3 = %d\n", 2 ** 3); // 8
|
||||
printf("2 ** 3 ** 2 = %d\n", 2 ** 3 ** 2); // 512
|
||||
|
||||
### NULL coalescing operator
|
||||
The ___??___ operator should return the left side as long as it's not null, in that case the right side would be returned.
|
||||
|
||||
int function() {
|
||||
$someValue = $this->GetValue();
|
||||
$defaultValue = 23;
|
||||
//result will be 23 if $someValue is NULL
|
||||
return $someValue ?? $defaultValue;
|
||||
}
|
||||
|
||||
### AUTO keyword
|
||||
Variables that are declared at method/closure scope could have an implicit type ___auto___. An implicitly typed local variable should be strongly typed just as if programmer had declared the type himself, but the compiler determines the type.
|
||||
|
||||
string $var = 'text' // Explicitly typed string
|
||||
auto $var = 'text'; // Implicitly typed string
|
||||
|
||||
### IS keyword
|
||||
The is operator could be used to check if the run-time type of an object is compatible with the given type or not. It should return true if the given object is of the same type otherwise, return false.
|
||||
|
||||
class A {
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
}
|
||||
|
||||
class C {
|
||||
}
|
||||
|
||||
class Prorgam {
|
||||
void main() {
|
||||
object $obj = new B();
|
||||
var_dump($obj is B); // true
|
||||
var_dump($obj is A); // true
|
||||
var_dump($obj is C); // false
|
||||
var_dump($obj is object); // true
|
||||
}
|
||||
}
|
||||
|
||||
### Operator overloading
|
||||
It should be possible to redeclare or overload most of the built-in operators available in AerScript. Thus a programmer could use operators with user-defined object types as well. 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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user