Example #1
0
func getOrMakeDict(vm *gelo.VM, name string) *gelo.Dict {
	k := gelo.StrToSym(name)
	dw, ok := vm.Ns.Get(0, k)
	var d *gelo.Dict
	if ok {
		d, ok = dw.(*gelo.Dict)
		if !ok {
			d = gelo.NewDict()
			vm.Ns.Set(0, k, d)
		}
	} else {
		d = gelo.NewDict()
		vm.Ns.Set(0, k, d)
	}
	return d
}
Example #2
0
File: dict.go Project: catb0t/gelo
func DictCon(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac == 0 {
		return gelo.NewDict()
	}
	if ac != 1 {
		gelo.ArgumentError(vm, "Dict", "{{k1 v1} {k2 v2} ... {kn vn}}", args)
	}
	d, ok := gelo.UnserializeDictFrom(args.Value)
	if !ok {
		gelo.RuntimeError(vm, "Cannot unserialize", args.Value, "into a dict")
	}
	return d
}