Embedded programming language for Zig
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add eval function

IamPyu 6afa270b bf5e58b8

+11 -8
+9
src/std/core.zig
··· 30 30 try scope.insert("and", try Value.initNativeFunc(scope, @"and")); 31 31 try scope.insert("or", try Value.initNativeFunc(scope, @"or")); 32 32 33 + try scope.insert("eval", try Value.initNativeFunc(scope, eval)); 33 34 try scope.insert("set", try Value.initNativeFunc(scope, set)); 34 35 try scope.insert("print", try Value.initNativeFunc(scope, print)); 35 36 try scope.insert("floop", try Value.initNativeFunc(scope, floop)); ··· 243 244 } 244 245 245 246 // -- FUNCTIONS -- 247 + 248 + pub fn eval(scope: *Scope, args: []const *Value) RuntimeError!*Value { 249 + if (args.len != 1) { 250 + return error.InvalidArguments; 251 + } 252 + 253 + return scope.evalExpr(args[0]); 254 + } 246 255 247 256 pub fn set(scope: *Scope, args: []const *Value) RuntimeError!*Value { 248 257 var iter = SliceIterator(*Value).init(args);
+2 -8
src/test/test7.zexa
··· 1 - (print "Hello World!") 2 - 3 - ;; (set 'double (lambda (x) 4 - ;; (mul x 2))) 5 - 6 - 7 - (while #t 8 - (rejfr)) 1 + (print "hello world") 2 + (undefined-function)