You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
put and get are actually polyadic functions which appear as such by the grace of the Shen reader. There is an optional final argument which should be a standard vector; thus (put Mark sex male (value myvector)) will use the vector myvector as the hashing table.
Running a similar code on shen-scheme, version 0.24, downloaded as a linux binary from the release page, will fail.
For example:
(put Mark sex male (vector 10))
Exception in hashtable-set!: #(10 shen.fail! shen.fail! shen.fail! shen.fail! shen.fail! shen.fail! shen.fail! shen.fail! shen.fail! shen.fail!) is not a hashtable
That is, the code fails as vector is not an hashtable.
This seems to be because the implementation uses the underlying system hashtables instead of shen vectors.
Indeed, the following works correctly:
(put Mark sex male (scm.make-hash-table))
male
The shen-cl implementation seems to provide the same behavior.
I expect that this is known and not a bug, but would it be possible to have the vector version working too? Otherwise, is there a way to make portable (between implementations) shen code that uses custom hash-maps with put/get?
If this is something that is possible or desired to change I'm open to help, within the limit of my abilities and knowing that I'm not versed in scheme, as I would like to be able to use the vector version.
The text was updated successfully, but these errors were encountered:
@diseraluca(shen.dict SizeHint) is what you want here. By default a vector is used to implement such dictionaries, but some ports will override it with a native hash table implementation for performance.
You have my deepest gratitude for the gentle pointer, the immediate response and your general work on the shen programming language.
Would you think it might be sensible to add a small note in the README about this to ease the confusion that may stem from TBOS and the shendoc webpage?
I'm thinking that for the sake of compatibility with what has already been put in print, the put and get functions probably need to work with vectors too in platforms that use native hash tables. Give me some time to think about what the best solution would be.
The book of shen 3rd edition, page 93 says:
On the next page, the following code snippet can be found:
Similarly, the shen shendoc page reports:
Running a similar code on shen-scheme, version 0.24, downloaded as a linux binary from the release page, will fail.
For example:
That is, the code fails as vector is not an hashtable.
This seems to be because the implementation uses the underlying system hashtables instead of shen vectors.
Indeed, the following works correctly:
The shen-cl implementation seems to provide the same behavior.
I expect that this is known and not a bug, but would it be possible to have the vector version working too? Otherwise, is there a way to make portable (between implementations) shen code that uses custom hash-maps with put/get?
If this is something that is possible or desired to change I'm open to help, within the limit of my abilities and knowing that I'm not versed in scheme, as I would like to be able to use the vector version.
The text was updated successfully, but these errors were encountered: