-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Initial support for tagged-literal
#180
base: main
Are you sure you want to change the base?
Conversation
@@ -499,6 +504,8 @@ jank_object_ptr jank_load_clojure_core_native() | |||
intern_fn("hash-unordered-coll", static_cast<native_hash (*)(object const *)>(&hash::unordered)); | |||
intern_fn("read-string", &core_native::read_string); | |||
intern_fn("jank-version", &core_native::jank_version); | |||
intern_fn("tagged-literal", &core_native::tagged_literal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where these two fns should live.
|
||
object base{ obj_type }; | ||
|
||
object_ptr tag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the tag should always be a symbol, but this was easier to get working for me.
return get(key, obj::nil::nil_const()); | ||
} | ||
|
||
object_ptr tagged_literal::get_entry(object_ptr /*key*/) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think get_entry
and contains
are supported by tagged-literals
on the jvm, so not sure what to do here.
} | ||
|
||
auto const s(expect_object<tagged_literal>(&o)); | ||
return tag == s->tag && form == s->form; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to be working:
% ./build/jank repl
Bottom of clojure.core
clojure.core=> (= (tagged-literal 'foo {}) (tagged-literal 'foo {}))
false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at similar code, I'm guessing runtime::equal
is more appropriate to compare tag and form as they are not interned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @frenchy64, that was it! I don't know why I assumed that ==
would be overloaded instead of providing reference equality.
Not done yet, but just wanted to put this up to make sure I was headed in the right direction.