Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use symbol-hashtables #6

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/Record/Unsafe.ss
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,32 @@
unsafeGet
unsafeSet
unsafeDelete)
(import (only (rnrs base) define lambda let)
(prefix (purs runtime) rt:)
(prefix (purs runtime srfi :125) srfi:125:))
(import (chezscheme)
(prefix (purs runtime) rt:))

(define unsafeHas
(lambda (label)
(lambda (rec)
(srfi:125:hash-table-contains? rec label))))
(symbol-hashtable-contains? rec (string->symbol label)))))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we're not going for bytestring->symbol just yet? Or will this not change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for being compatible with new symbol-based hashtables, we don't have bytestrings yet.


(define unsafeGet
(lambda (label)
(lambda (rec)
(rt:object-ref rec label))))
(rt:object-ref rec (string->symbol label)))))

(define unsafeSet
(lambda (label)
(lambda (value)
(lambda (rec)
(let ([rec-copy (rt:object-copy rec)])
(rt:object-set! rec-copy label value)
(rt:object-set! rec-copy (string->symbol label) value)
rec-copy)))))

(define unsafeDelete
(lambda (label)
(lambda (rec)
(let ([rec-copy (rt:object-copy rec)])
(srfi:125:hash-table-delete! rec-copy label)
(symbol-hashtable-delete! rec-copy (string->symbol label))
rec-copy))))

)
Loading