Some examples in "debraced" mode, indentation completely missing, add 
parentheses/braces at will, DYI, it will get parsed anyway. functions at the 
"zero-level" (no embracing parantheses) need to be defined at the beginning of 
a line...
    
    
    import stdio.h
    
    faculty proc(int n) int = return n * faculty(n-1)
    fn(0) = 1
    
    main proc(int argc,char argv*[]) = for a in argv[0..<argc] : printf "%s\n",a
    printf  "%d\n", faculty(3)
    
    # output: the command line items, then prints "6".
    # pointwise definition of faculty at value "0" , proc name "borrowed" from 
actual definition
    # now an old-style definition of main, however no semicolon required
    main proc(int argc,char argv*[]) { int a;
    for (a=0; a<argc; a += 1)  printf ("%s\n",argv[a]);
    printf  ("%d\n", faculty(3))
    }
    # compiler would eventually give a warning because of the missing ":" after 
for
    # However, since the compiler basically presumes line-orientation, the 
semicola could be removed.
    # and now, a proc as  a lambda, not supported by C. The ":=" helps with  
type inference.
    x := (proc(...)int = ...... )
    # we get a x() and might even get a closure. This is not c-idiomatic 
anymore, of course.
    # Anyway, we can expect automatic dereferencing , so we can use x(....) .
    # ... as already provided within C as standard behaviour. Now, let's 
rewrite faculty:
    faculty proc(n) = return n * faculty(n-1)
    fn 0 = 1
    # compiler should be able to type it for us, why not......
    
    
    
    Run

nim

Reply via email to