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

added thaw to complement freeze #1142

Merged
merged 3 commits into from May 21, 2023
Merged

added thaw to complement freeze #1142

merged 3 commits into from May 21, 2023

Conversation

tionis
Copy link
Contributor

@tionis tionis commented May 19, 2023

Relevant issue: #1092
Not sure if all cases are handled here.

@sogaiu
Copy link
Contributor

sogaiu commented May 19, 2023

(Sorry my original comment was confused / wrong -- hopefully this latest version is better.)

May be prototype stuff is not being handled:

(def ds
  (struct/with-proto {:b 2} :a 1))

(get ds :a)
# =>
1

(get ds :b)
# =>
2

(get (thaw ds) :a)
# =>
1

(get (thaw ds) :b)
# =>
nil

@tionis
Copy link
Contributor Author

tionis commented May 20, 2023

Interesting, I'll look into it. Thanks!

@tionis
Copy link
Contributor Author

tionis commented May 20, 2023

OK, prototypes don't appear in normal lookups, I guess I could check recursively for prototypes in structs and maps and inline them with the uppermost struct. Not sure about the performance implications of that approach, but I'll implement it quickly.

@tionis
Copy link
Contributor Author

tionis commented May 20, 2023

Oh nevermind, I can just use proto-flatten

@tionis
Copy link
Contributor Author

tionis commented May 20, 2023

Ok, should be fixed now

@sogaiu
Copy link
Contributor

sogaiu commented May 20, 2023

Worked here too 👍

Will you be adding any tests?

@zevv
Copy link
Contributor

zevv commented May 20, 2023

Minor comment: maybe handle the different types in the same order as (freeze) does, which makes it harder to compare the implementations and maybe later add different types.

@tionis
Copy link
Contributor Author

tionis commented May 20, 2023

I added simple tests for thaw and freeze and reordered the types in the implementation

@sogaiu
Copy link
Contributor

sogaiu commented May 20, 2023

On a side note, going over the tests I started to wonder whether it would be worth having functions like mutable? / immutable? and may be deep-* versions.

I didn't see any functions like that already, but I don't know if they'd be that useful.

@bakpakin bakpakin merged commit c3fd71d into janet-lang:master May 21, 2023
7 checks passed
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.

None yet

4 participants