Carp
Carp copied to clipboard
Dynamic Map (dictionary)
I think adding dynamic maps (using the existing { key value, key value }
syntax would be a nice and not overly hard thing to do. Obviously it should replicate as much as possible of the existing functionality (and names) of the static Map
module.
One interesting design choice is whether to have something like the keywords of Clojure (e.g. :stuff
) or if we're fine with just symbols, which would look something like this:
{ 'stuff 10, 'more-stuff 20 }
What do you all think?
Neat! At first I kind of missed :key
syntax in carp, but at this point I kind of like it's absence, actually. I think it makes things simpler.
If we plan on introducing keyword arguments, I think using :key
or something similar is probably necessary, but I think for this case just a symbol should be fine!
Would you be able to mix types?
Would you be able to mix types?
It should allow that, I think--dynamic code isn't type checked. Should likely work the same as lists and arrays in dynamic code:
鲤 '[1 a b]
=> [1 a b]
鲤 [1 a b]
Can't find symbol 'a' at REPL:1:4.
鲤
Nice, might rewrite Hoquet as a macro if that lands.
Yeah I agree, it should be just as dynamic as dynamic arrays, functions, etc.
As we have them now, what is left to do here?