After fidgeting with the syntax, here's what I got:
$def iterable-object ->
[ %set -> x k o n
[ @x %keys -> ~ (pushnew (keys x) k) ]
%rem -> x k o
[ @x %keys -> ~ (pull (keys x) k) ]
%keys -> ~ {} ]
I actually realized that swapping [] and {} is way better, meaning that [ foo bar ] is (dict foo bar) and { foo bar } is (array foo bar). There's two reasons for this:
1) {} is closer to () than [] is, which is really nice in macros:
$mac $accessor -> n v
$uniq %a
{$def n -> %a
{{%a v} %a}}
2) I found that {} didn't stand out enough, but [] does.
---
By the way, in case you're curious about the Nulan syntax... $ is prefixed to vau/macros, which is why it's "$def" rather than "def"
-> is the function macro, which means (-> x y z ...) is equivalent to (fn (x y z) ...) in Arc
~ is the "wildcard syntax" which matches anything, just like _ in Haskell
[ foo bar ] translates to (dict foo bar), and { 1 2 3 } translates to (array 1 2 3)
@ is for splicing. Which means that [ @foo @bar @qux ] merges three objects into one. If you want to update an object with new properties, it's idiomatic to say [ @foo ... ]
Which, if translated into JavaScript, would look something like this...
var iterableObject = function () {
var a = {};
a.set = function (x, k, o, n) {
var a = Object.create(x);
a.keys = function () {
return pushnew(keys(x), k)
}
};
a.rem = function (x, k, o) {
var a = Object.create(x);
a.keys = function () {
return pull(keys(x), k)
}
};
a.keys = function () {
return []
};
return a
}