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

JBIND/JMATCH: better optional value syntax (default values? nested destructuring?) #8

Open
aartaka opened this issue Oct 6, 2023 · 1 comment
Labels
backwards-incompatible Backwards-incompatible changes for next major release. bug Something isn't working good first issue Good for newcomers

Comments

@aartaka
Copy link
Contributor

aartaka commented Oct 6, 2023

Right now, jbind/jmatch destructuring patterns can contain the (var &optional var-p) list to denote an optional object property or array element. However, this syntax doesn't allow providing default value for the case this optional value is not provided. CL-native optional arguments allow that, and it's useful.

So the syntax should be extended to

(var &optional default-value var-p)

It's not backwards-compatible, so it can only happen on the next major release.

@aartaka aartaka added bug Something isn't working good first issue Good for newcomers backwards-incompatible Backwards-incompatible changes for next major release. labels Oct 6, 2023
@aartaka aartaka changed the title jbind/jmatch: better optional value syntax with default values jbind/jmatch: better optional value syntax (var &optional default-value var-p) Oct 6, 2023
@aartaka aartaka changed the title jbind/jmatch: better optional value syntax (var &optional default-value var-p) JBIND/JMATCH: better optional value syntax (default values) Oct 6, 2023
@aartaka
Copy link
Contributor Author

aartaka commented Oct 11, 2023

Alternatively, use the second value as the nested destructuring pattern, so that one can destructure inside the object when it's present, and get NIL is it's not. Seems pretty intuitive for a destructuring macro?

@aartaka aartaka changed the title JBIND/JMATCH: better optional value syntax (default values) JBIND/JMATCH: better optional value syntax (default values? nested destructuring?) Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-incompatible Backwards-incompatible changes for next major release. bug Something isn't working good first issue Good for newcomers
Development

No branches or pull requests

1 participant