convert function call to builtInCall in setvariable, and add OOP example

This commit is contained in:
2023-06-21 20:36:06 +01:00
parent ae08f059fb
commit 9fe8bcb515
8 changed files with 59 additions and 56 deletions

View File

@@ -195,23 +195,6 @@ func makeGlobal() ArObject {
return ArArray([]any{}), ArErr{}
}}
vars["subprocess"] = builtinFunc{"subprocess", ArSubprocess}
vars["object"] = builtinFunc{"object", func(a ...any) (any, ArErr) {
if len(a) == 0 {
return nil, ArErr{TYPE: "TypeError", message: "Cannot create class from '" + typeof(a[0]) + "'", EXISTS: true}
}
switch x := a[0].(type) {
case ArObject:
if typeof(x) == "object" {
return x, ArErr{}
}
newclass := ArObject{obj: anymap{}}
for key, val := range x.obj {
newclass.obj[key] = val
}
return newclass, ArErr{}
}
return nil, ArErr{TYPE: "TypeError", message: "Cannot create class from '" + typeof(a[0]) + "'", EXISTS: true}
}}
vars["sequence"] = builtinFunc{"sequence", ArSequence}
vars["exit"] = builtinFunc{"exit", func(a ...any) (any, ArErr) {
if len(a) == 0 {