This now type checks. It's starting to feel real... union IntOrPtr { i: int; p: int*; } var u1 = IntOrPtr{i = 42} var u2 = IntOrPtr{p = cast(int*, 42)} var a: int[256] = {1, 2, ['a'] = 3}
-
-
Replying to @pervognsen
Awesome except for those “var” keywords. Why not eliminate that and use a=1 or a:int=1 for new declarations and a:=1 for writes to existing symbols? Or better yet require explicit mutability through a TVar/IOVar style abstraction?
3 replies 0 retweets 3 likes -
-
Replying to @pervognsen @TimSweeneyEpic
I like having keywords signposting each declaration at the top level, and the local shorthand is available inside function bodies.
1 reply 0 retweets 1 like -
Replying to @pervognsen
Here, let me redesign that syntax for you :-) IntOrPtr=union{ i: int; p: ^int; } u1=IntOrPtr{i = 42} u2=IntOrPtr{p = cast(^int, 42)} a:[256]int={1, 2, ['a'] = 3}
1 reply 0 retweets 1 like -
This Tweet is unavailable.
-
Putting type symbols on the left and access symbols on the left creates a symmetry between “definition by type” and “definition by example”: x:^int # x is a pointer to an int x^:int # x dereferenced is an int f:int->int f(x:int):int
1 reply 0 retweets 0 likes
left* right* This is a syntactic principle many languages partly implemented, but I’ve never seen explicitly stated or systematically implemented.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.