Giter Site home page Giter Site logo

Comments (8)

leppie avatar leppie commented on August 17, 2024

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.

leppie avatar leppie commented on August 17, 2024

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.

2bt avatar 2bt commented on August 17, 2024

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.

leppie avatar leppie commented on August 17, 2024

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.

christoff-buerger avatar christoff-buerger commented on August 17, 2024

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.

leppie avatar leppie commented on August 17, 2024

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.

leppie avatar leppie commented on August 17, 2024

@christoff-buerger Should be fixed in last commit, let me know if you pick up issues.

from ironscheme.

christoff-buerger avatar christoff-buerger commented on August 17, 2024

It works! Thanks a lot!

from ironscheme.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.