September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,24 @@
fcn{"Hello World"} // no expected args
fcn(){"Hello World"} // ditto
fcn{vm.arglist}(1,2) // ask the VM for the passed in args -->L(1,2)
fcn f(a,b){a+b} // fcn(1,2,3) works just fine
fcn f(args){}(1,2,3) //args = 1
fcn(args){vm.arglist.sum()}(1,2,3) //-->6
fcn(a=1,b=2){vm.arglist}() //-->L(1,2)
fcn(a=1,b=2){vm.arglist}(5) //-->L(5,2)
fcn(a=1,b){vm.arglist}() //-->L(1), error if you try to use b
fcn(a,b=2){vm.arglist}(5) //-->L(5,2)
fcn(a,b=2,c){vm.arglist}(1) //-->L(1,2)
fcn(){vm.nthArg(1)}(5,6) //-->6
fcn{vm.numArgs}(1,2,3,4,5,6,7,8,9) //-->9
fcn{vm.argsMatch(...)} // a somewhat feeble attempt arg pattern matching based on type (vs value)
// you can do list assignment in the prototype:
fcn(a,[(b,c)],d){vm.arglist}(1,L(2,3,4),5) //-->L(1,L(2,3,4),5)
fcn(a,[(b,c)],d){"%s,%s,%s,%s".fmt(a,b,c,d)}(1,L(2,3,4),5) //-->1,2,3,5
// no type enforcement but you can give a hint to the compiler
fcn([Int]n){n.sin()} //--> syntax error as Ints don't do sin