Carp icon indicating copy to clipboard operation
Carp copied to clipboard

Dynamic Map (dictionary)

Open eriksvedang opened this issue 4 years ago • 6 comments

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?

eriksvedang avatar May 23 '20 05:05 eriksvedang

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!

scolsen avatar May 23 '20 15:05 scolsen

Would you be able to mix types?

TimDeve avatar Jun 04 '20 16:06 TimDeve

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.
鲤 

scolsen avatar Jun 04 '20 16:06 scolsen

Nice, might rewrite Hoquet as a macro if that lands.

TimDeve avatar Jun 04 '20 16:06 TimDeve

Yeah I agree, it should be just as dynamic as dynamic arrays, functions, etc.

eriksvedang avatar Jun 04 '20 17:06 eriksvedang

As we have them now, what is left to do here?

hellerve avatar Feb 17 '22 19:02 hellerve