forked from alex-eg/sex
move Sex to better types
Types, fns and vars are now written in another, better, more intuitive and readable way. Types: "pointer to const char" is "* const char" "array of pointers to volatile int" is "[* volatile int]" Read left to right Vars (as well as fn args, struct fields): (var name type) (struct vec3 ((x float) (y float) (z float)) (fn vec3-add ((v1 vec3) (v2 vec3)) vec3 ...) Also fns are now have return types after arg list. * is now must not be attached to any type name (or variable for that matter)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
(include stdio.h)
|
||||
|
||||
(pub fn int main ((int argc) (char **argv))
|
||||
(pub fn main ((argc int) (argv [* const char])) int
|
||||
(puts "Hello from Sex!")
|
||||
(var (array char 512) name)
|
||||
(var name [char 512])
|
||||
(puts "What is your name?")
|
||||
(scanf "%s" (cast char* &name))
|
||||
(scanf "%s" (cast (& name) (* char)))
|
||||
(printf "Hello, %s!\n" name)
|
||||
(return 0))
|
||||
|
||||
Reference in New Issue
Block a user