Comments (8)
Hmmm, this is interesting. An empty list is a null
and it is exactly that in IronScheme/CLR. I will see what I can do :)
Thanks
from ironscheme.
Unfortunately, this is a limitation with the .NET implementation of hashtables...
I could work around it, by creating some substitute for null but it seems hacky, and then you have differences in behavior between .NET and IronScheme which I try my best to avoid.
I will think about it a bit more.
from ironscheme.
In the meantime, I've been doing something like this:
(define-record-type nil-record (sealed #t) (opaque #t))
(define nil (make-nil-record))
(define hashtable-ref*
(lambda (h k d)
(hashtable-ref h (if (null? k) nil k) d)))
(define hashtable-set!*
(lambda (h k v)
(hashtable-set! h (if (null? k) nil k) v)))
(define hashtable-delete!*
(lambda (h k)
(hashtable-delete! h (if (null? k) nil k))))
(define hashtable-contains?*
(lambda (h k)
(hashtable-contains? h (if (null? k) nil k))))
(define hashtable-entries*
(lambda (h)
(let-values
(((kv vv) (hashtable-entries h)))
(let ((n (vector-length kv)))
(do ([i 0 (+ i 1)])
((= i n))
(when (eq? (vector-ref kv i) nil) (vector-set! kv i '()))))
(values kv vv)))))
You're right. It feels very hacky and I'm not happy with it. But I need this behaviour of a project. Do you maybe have a better idea? Great work, btw.
from ironscheme.
That's about right.
You could probably use vector-map
instead of the do
in the last proc.
If you really want to you can use macros to clean it up, but IMO it is too much effort in this case.
Eg:
(define-syntax-rule (null/subst k) (if (null? k) nil k))
from ironscheme.
I will think about it a bit more.
Will this be fixed or does...
I could work around it, by creating some substitute for null but it seems hacky, and then you have differences in behavior between .NET and IronScheme which I try my best to avoid.
...outweigh R6RS conformance?
At the moment I use boilerplate code like above to create a special nil-record used in case of empty lists as keys. Its bothersome and fragile however, to maintain several product versions for different Scheme implementations.
from ironscheme.
I was thinking of building it into IronScheme libraries, but need to investigate. I think some hashtable procedure(s) are still done in C# which makes it tricky.
from ironscheme.
@christoff-buerger Should be fixed in last commit, let me know if you pick up issues.
from ironscheme.
It works! Thanks a lot!
from ironscheme.
Related Issues (20)
- "Type not found" in Windows Forms code HOT 5
- Unable to locate clr-... functions HOT 1
- Problem inferring clr type and unable to call inner classes HOT 4
- clr-call: Overload resolution might chose wrong but compatible method when generics are used HOT 2
- Visual Studio IronScheme Integration HOT 1
- IronScheme website HOT 3
- Can pretty-printing for quote/quasiquote/unquote be disabled for write or display? HOT 5
- EvalWithEnvironment doesn't seem to work when given an importspec and arguments for substitution. HOT 9
- Add tracing for internal operations HOT 1
- Regression symbol string mapping in 1.0.312 HOT 2
- R7RS support HOT 4
- (atan +inf.0+0.0i) returns NaNs
- Wrong target directory when compiling libraries HOT 2
- Tail calls inside of a guard are not treated as tail calls. HOT 6
- BinaryFormatter replacement HOT 3
- Console adds UTF-8 BOM to output HOT 11
- Library fails to compile on .NET Core HOT 4
- Target .NET Framework 4 and overall "modernization" HOT 8
- Move CI to Github Actions instead of AppVeyor HOT 1
- Implement precompiling libraries on .NET 9 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ironscheme.