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

Null ref #11

Merged
merged 4 commits into from
Jan 19, 2023
Merged

Null ref #11

merged 4 commits into from
Jan 19, 2023

Conversation

capital-G
Copy link
Member

@capital-G capital-G commented Jan 16, 2023

Closes #7 and closes #5

BTW, why is

`nil === `nil
-> false
`nil == `nil
-> false

@capital-G capital-G requested a review from telephon January 16, 2023 12:13
@telephon
Copy link
Contributor

telephon commented Jan 16, 2023

Two refs

BTW, why is

`nil === `nil
-> false

This is clear, two refs are two separate objects.

`nil == `nil
-> false

I suppose one could argue for this being true and implementing it in Ref (one needs == and hash).
But in our case, we don't absolutely need it, we can write x.class == Ref and: { x.value.isNil }.

@@ -31,7 +28,7 @@ JSONlib {
var array;
^case
{ v.isKindOf(Symbol) } { this.prConvertToJson(v.asString) }
{ v == "null" or: { v.class == JSONlibNull } or: { v == nil } } { "null" }
{ v == "null" or: { v.value == nil } or: { v == nil } } { "null" }
Copy link
Contributor

Choose a reason for hiding this comment

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

we should check for Ref class. Otherwise, you may lose a function like { |x| x !? (x+1) }

Copy link
Contributor

Choose a reason for hiding this comment

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

... and it is confusing that we use the null string. Let's do two things only:
{ v.isNil or: { v.class == Ref and: { v.value.isNil } } }

Copy link
Member Author

Choose a reason for hiding this comment

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

good point - can you check if it is better now?

@capital-G capital-G requested a review from telephon January 16, 2023 13:25
@@ -28,7 +28,8 @@ JSONlib {
var array;
^case
{ v.isKindOf(Symbol) } { this.prConvertToJson(v.asString) }
{ v == "null" or: { v.value == nil } or: { v == nil } } { "null" }
// only check value if it is a ref
{ (v.isKindOf(Ref)).if({v.value==nil}, {false}) or: { v == nil } } { "null" }
Copy link
Contributor

Choose a reason for hiding this comment

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

please instead of

{ (v.isKindOf(Ref)).if({v.value==nil}, {false}) or: { v == nil } } { "null" }

make it

{ v.isNil or: { v.isKindOf(Ref) and: { v.value.isNil } } } { "null" }

Copy link
Member Author

Choose a reason for hiding this comment

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

Imlpemented

@capital-G capital-G requested a review from telephon January 17, 2023 21:15
@telephon telephon merged commit f5c7460 into main Jan 19, 2023
@capital-G capital-G deleted the null-ref branch January 20, 2023 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nil –> "null" Replace JSONlibNull with Nil
2 participants