summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-07-01 14:43:21 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-03 23:27:02 -0700
commitca10a1ec838b7d468a2b43894af659c111a0e9b1 (patch)
tree16601ac01a6f644015188db074e1c2b69bdc5789 /doc
parentddb327c92ebe3f96c5c816ec61996440551de401 (diff)
downloadmc-ca10a1ec838b7d468a2b43894af659c111a0e9b1.tar.gz
Add impl(type, name) to retrieve a particular implementation of a trait decl
This avoids having to create a temporary variable when you know what implementation your want for a generic constant or function with generic return value. Re-use the impl keyword for this expression to avoid invalidating existing programs.
Diffstat (limited to 'doc')
-rw-r--r--doc/lang.txt10
1 files changed, 8 insertions, 2 deletions
diff --git a/doc/lang.txt b/doc/lang.txt
index 0f14322..3be5500 100644
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -1239,7 +1239,8 @@ TABLE OF CONTENTS:
5.2.3. Atomic Expressions:
atomicexpr: ident | gap | literal | "(" expr ")" |
- "sizeof" "(" type ")" | castexpr
+ "sizeof" "(" type ")" | castexpr |
+ "impl" "(" name "," type ")"
castexpr: "(" expr ":" type ")"
gap: "_"
@@ -1265,6 +1266,10 @@ TABLE OF CONTENTS:
match, again, given that it is never read from in the body of the
match.
+ An impl expression chooses the implementation of the given trait
+ declaration for the given type. It is useful for refering to trait
+ declarations in a generic context.
+
5.2.4. Cast Expressions:
Cast expressions convert a value from one type to another. Some
@@ -2012,7 +2017,8 @@ TABLE OF CONTENTS:
postepxr "#" |
atomicexpr
- atomicexpr: ident | literal | "(" expr ")" | "sizeof" "(" type ")"
+ atomicexpr: ident | literal | "(" expr ")" | "sizeof" "(" type ")" |
+ "(" expr ":" type ")" | "impl" "(" name "," type ")"
/* literals */
literal: funclit | seqlit | tuplit | simplelit