I came up with a weird data structure. It’s a hash, but you can also add functions that receive the hash as input so you can do math with it (if you squint, it’s vaguely like a spreadsheet). Something like:
m = MagicDict()
m["a"] = 1
m["b"] = 2
m["sum"] = lambda self: self["a"] + self["b"]
print(m["sum"])
Ideally, I’d want to do this in #RakuLang. (I know it’s possible because I did something much weirder once (I gave Str a CALL-ME method).)
@julia pretty sure we already have those; in Perl they are called “packages”