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

Add std/misc/walist #744

Merged
merged 2 commits into from
Jul 31, 2023
Merged

Add std/misc/walist #744

merged 2 commits into from
Jul 31, 2023

Conversation

fare
Copy link
Collaborator

@fare fare commented Jul 29, 2023

Add a library for wrapped alists: alists in a box, such that the equality predicate is transported with the data, and, when stateful, the empty alist is properly handled.

Use walist to enable user-controled field order when printing json objects.

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

Can we please separate the json stuff in different pr?
Or alternatively base this on the json-stdio branch and target that pr?

Merging this as is will create horrendous conflicts that we should avoid.

@vyzo
Copy link
Collaborator

vyzo commented Jul 30, 2023

I would suggest the following hierarchy:

walist ; equal?
(walistq walist) ; eq?
(walistv walist) ; eqv?
walist! ; mutable, disjoing from immutables
(walistq! walist!) ; mutable eq?
(walistv! walist!) ; mutable eqv?

And then you can write a macro that implements the methods and specialize accordingly.

src/std/misc/walist-test.ss Outdated Show resolved Hide resolved
:std/sugar)

(export
_walist_ _walist_?
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we avoid exporting those two?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or at least rename them, these are ugly names.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What names would you suggest? They are what std/text/json uses to recognize it's being given a walist.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

base-walist ? wrapped-alist ?

Copy link
Collaborator

@vyzo vyzo Jul 30, 2023

Choose a reason for hiding this comment

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

lets call the base walist, thats what the users will be working with.
Also, the accessor should be export renamed to walist->list i think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the base is walist, what is the pure equal one called? The same, and I override the rest? Then it's not final?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why walist->list rather than walist->alist ?

@fare fare changed the title Add std/misc/walist, use it in std/text/json Add std/misc/walist Jul 30, 2023
Pure and stateful wrapped alists, carry with them the equality predicate
and, for the stateful ones, correctly handle the case of empty alists.
@fare
Copy link
Collaborator Author

fare commented Jul 30, 2023

What do you think of this refactoring? If you like it, I can squash the commits together.

Refactor the wrapped alist type hierarchy.
Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

LGTM.
Feel free to squash merge.

@fare fare merged commit b4a3e8a into mighty-gerbils:master Jul 31, 2023
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.

2 participants