calysto_scheme icon indicating copy to clipboard operation
calysto_scheme copied to clipboard

Different indistinguishable dicts

Open CoffeeImpliesCode opened this issue 3 years ago • 1 comments

Hi, I noticed (after some troubleshooting) that dicts created by (dict ...) and by (python-eval "...") look exactly the same but behave differently:

(define a (python-eval "{'a' : 1}"))
a                                                           => {'a' : 1}
(define b (dict '(b : 2)))
b                                                           => {'b' : 2}
(get-item a 'a)                                             => 1
(get-item b 'b)                                             => error
(get-item a "a")                                            => 1
(get-item b "b")                                            => 1

While I know that that behaviour is to be expected, couldn't its representation be different to emphasize the incompatibility? e.g. b => {"b" : 2} or change the symbol-based one a => {'a : 2}

CoffeeImpliesCode avatar Jan 27 '21 04:01 CoffeeImpliesCode

If you could make a pull request, that would be great.

dsblank avatar Jan 27 '21 16:01 dsblank

Fixed in Calysto Scheme 1.4.8. All dictionaries use strings as keys, but now will automatically convert symbols to strings if needed. Thanks for reporting!

dsblank avatar May 15 '23 14:05 dsblank