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

Individual record field access #46

Open
j14159 opened this issue Nov 6, 2016 · 1 comment
Open

Individual record field access #46

j14159 opened this issue Nov 6, 2016 · 1 comment

Comments

@j14159
Copy link
Collaborator

j14159 commented Nov 6, 2016

At the moment we can only access members of records via a pattern match but we need to be able to do

let r = {x=1, y=2} in
  r.x + 2

I think this will require rewriting the AST in or before the code generation stage to put a pattern match up front, e.g. in Erlang:

case r of
    #{'__struct__' := record, 'x' := R_x} ->  R_x + 2
@yurrriq
Copy link
Contributor

yurrriq commented Mar 19, 2017

https://github.com/rvirding/lfe/blob/develop/src/lfe_macro_record.erl might be of interest here. Basically it takes record definitions and generates make- and match- macros (which we don't need in Alpaca) as well macros for getting all fields, and getting and setting individual fields. The compiler could desugar r.x to get_rec_x r.

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

2 participants