Ver Fonte

Update documentation.

Vladislav Folts há 9 anos atrás
pai
commit
5b8681545d

+ 1 - 1
doc/wiki/eberon-implicit-type-narrowing.md

@@ -13,7 +13,7 @@ The idea of *implicit type narrowing* is to make the compiler smart enough to co
         ASSERT(~(pb IS PDerived) OR (pb.derivedField = 123));
         ASSERT(~(pb IS PDerived) OR (pb.derivedField = 123));
     END.
     END.
 
 
-Type narrowing is also applies for WHILE statement and its ELSIF branches.
+Type narrowing is also applies to [[Ternary operator|eberon-ternary-operator]], WHILE statement and its ELSIF branches.
 
 
 ### Generic Message Bus
 ### Generic Message Bus
 *Implicit type narrowing* is also used for VAR arguments to support generic message bus pattern.
 *Implicit type narrowing* is also used for VAR arguments to support generic message bus pattern.

+ 15 - 2
doc/wiki/eberon-ternary-operator.md

@@ -5,7 +5,8 @@ Ternary operator can be used as a shortcut for the IF/ELSE statement.
 	condition ? a : b
 	condition ? a : b
 
 
 _condition_ is a boolean expression.  
 _condition_ is a boolean expression.  
-_a_ and _b_ are expressions to evaluate. The operator returns _a_ when condition is TRUE and _b_ when condition is FALSE.
+_a_ and _b_ are expressions to evaluate.  
+The operator returns _a_ when condition is TRUE and _b_ when condition is FALSE. Ternary operator has lowest priority.
 
 
 ### Example
 ### Example
 
 
@@ -25,4 +26,16 @@ This code above may be rewritten in much shorter and cleaner manner using ternar
 
 
 	PROCEDURE max(a, b: INTEGER): INTEGER;
 	PROCEDURE max(a, b: INTEGER): INTEGER;
 		RETURN a > b ? a : b;
 		RETURN a > b ? a : b;
-	END;
+	END;
+
+### Implicit Type Narrowing
+
+Ternary operator supports [[Implicit Type Narrowing|eberon-implicit-type-narrowing]]:
+
+    TYPE
+        Base = RECORD END;
+        Derived = RECORD (Base) derivedField: INTEGER END;
+
+    PROCEDURE p(VAR b: Base): INTEGER;
+        RETURN b IS Derived ? b.derivedField : 0
+    END;        

+ 1 - 2
doc/wiki/eberon.md

@@ -15,9 +15,8 @@ Eberon basically extends original Oberon (excluding additional [restrictions](#r
 * [[Record fields read-only export|eberon-record-fields-read-only-export]]
 * [[Record fields read-only export|eberon-record-fields-read-only-export]]
 * [[Procedure call result can be denoted|eberon-procedure-call-result]]
 * [[Procedure call result can be denoted|eberon-procedure-call-result]]
 * [[Operator NEW|eberon-operator-NEW]]
 * [[Operator NEW|eberon-operator-NEW]]
-* [[Ternary operator||eberon-ternary-operator]]
+* [[Ternary operator|eberon-ternary-operator]]
 * [[Syntax relaxations|eberon-syntax-relaxations]]
 * [[Syntax relaxations|eberon-syntax-relaxations]]
-* Non-scalar variables (arrays and records) can be exported (forbidden in oberon for some unknown reason).
 
 
 ### Restrictions
 ### Restrictions
 * [[Non-VAR arguments are read-only|eberon-non-VAR-arguments-are-read-only]]
 * [[Non-VAR arguments are read-only|eberon-non-VAR-arguments-are-read-only]]