Keyword Proposal
The final keywords are:
def for global function definitions
fn for local function definitions/anonymous functions
if and else for if-else expressions
let for let bindings
True and False for 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
Let Expressions and Mutation
Immutable
let %x = 2;
let %x = 3;
let %y = 4;
%x + %y
Side Effects Only
The following are equivalent
let %_ = print("hello");
1
Tuples
Types
Base Types
Designed to look like NumPy types.
int32
uint32
float32
bool
int32x4
...
Shape Types
unimplemented
Tensor Annotations
generics unimplemented
def @add(t1: Tensor[s, bt], t2: Tensor[s, bt]) -> Tensor[s, bt] {
...
}
Function Types
fn (int32, int32) -> int32
Keyword Proposal
The final keywords are:
deffor global function definitionsfnfor local function definitions/anonymous functionsifandelsefor if-else expressionsletfor let bindingsTrueandFalsefor booleansfloat32x4Loose 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
Named, Inferred
Anonymous, Typed
Anonymous, Inferred
Let Expressions and Mutation
Immutable
Side Effects Only
The following are equivalent
Tuples
Types
Base Types
Designed to look like NumPy types.
Shape Types
unimplemented
Tensor Annotations
generics unimplemented
Function Types