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

Match body traversal algorithm #3

Open
chouzar opened this issue Nov 27, 2024 · 0 comments
Open

Match body traversal algorithm #3

chouzar opened this issue Nov 27, 2024 · 0 comments

Comments

@chouzar
Copy link
Owner

chouzar commented Nov 27, 2024

Erlang matchspecs are composed of tuple functions of 3 parts:

MatchFunction ::= { MatchHead, MatchConditions, MatchBody }

Usually literal values will be interpreted "as is" on the head or body with the exception of tuples and records on the MatchBody, as the engine requires those to be wrapped in a single element tuple.

Examples

To represent the tuple #(1, 2, 3) we will require:

let body = #(#(1, 2, 3))

To represent the record User(name: "Raúl") we will require:

let body = #(#(tag("user"), "Raúl"))

Instead of having the user specifying double tuples everywhere in the body we could automate it, can be done for primitives but the hard part is how to solve for custom datastructures.

This is partially implemented in v0.4.1.

@chouzar chouzar changed the title Match body traversal algorith Match body traversal algorithm Nov 27, 2024
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

No branches or pull requests

1 participant