jscl
jscl copied to clipboard
Make hash-table support numbers as keys
This allows numbers to be used as hash-table keys, since they are crudely converted to strings.
Closes #424
@nagy, thanks. Sorry, very busy lately. I'll take a look at the code this weekend.
I think a requirement for this change is that (gethash 1 ht)
should be different from (gethash "1" ht)
, of even for JS objects.
For #'eq
hash tables, we could just probably use a Map.
But that doen't solve the problem for #'eql
hash-tables.
that (gethash 1 ht) should be different from (gethash "1" ht)
You are right, I will think of a different approach.
May be we can store keys as strings like "TYPE:VALUE", for example "1" will be converted to "string:1" and 1 will be "number:1", etc.
To my surprise, that distinction between numbers and strings is already happening correctly. I have split the commit into two and added some more test and wrote some reasoning into the commit message.
Please check if it is fine now.
Awesome! Thanks!