-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Description
Keyword Proposal
The final keywords are:
deffor global function definitionsfnfor local function definitions/anonymous functionsifandelsefor if-else expressionsletfor let bindingsTrueandFalsefor booleans- data types are tvm-style. e.g.
float32x4
Loose Ends
There are some elements of the text format that didn't make it into this PR. See #1935 for details.
Please comment on syntax design choices for #1781 here!
Notable Syntax Examples
Functions
Named, Typed
def @foo(%x: int64, %y: int64) -> int64 {
%x + %y
}
Named, Inferred
def @foo(%x, %y) {
%x + %y
}
Anonymous, Typed
fn (%x: int64, %y: int64) -> int64 {
%x + %y
}
Anonymous, Inferred
fn (%x, %y) {
%x + %y
}
Let Expressions and Mutation
Immutable
let %x = 2;
let %x = 3;
let %y = 4;
%x + %y
Side Effects Only
The following are equivalent
print("hello");
1
let %_ = print("hello");
1
Tuples
()
(0,)
(0, 1)
Types
Base Types
Designed to look like NumPy types.
int32
uint32
float32
bool
int32x4
...
Shape Types
unimplemented
s
(n + 1, 2 * n, 4)
Tensor Annotations
generics unimplemented
def @add(t1: Tensor[s, bt], t2: Tensor[s, bt]) -> Tensor[s, bt] {
...
}
Function Types
fn (int32, int32) -> int32
junrushao