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

Records #15

Closed
5 tasks done
akovari opened this issue Mar 14, 2019 · 2 comments
Closed
5 tasks done

Records #15

akovari opened this issue Mar 14, 2019 · 2 comments
Assignees
Milestone

Comments

@akovari
Copy link
Member

akovari commented Mar 14, 2019

  • Implemented using tuples, where the first element is the name of the record

  • Syntax sugar, derived from tuple syntax, that is removed during parsing

  • Records are module scoped

  • Declaration syntax:

record Person = (first_name, last_name)

  • New record syntax:

let person = Person(first_name = "Adam") # at least one field is required, although it can technically be ()

  • Field access syntax:

person.first_name

  • Pattern matching syntax:

fun Person(first_name=f, last_name=l) # where f and l are bound to the values of first/last name from that record

fun p@Person # way to access the whole record in pattern matching, similar to sequences for example

  • Update record field:

let new_record = old_record(field = value)

@akovari
Copy link
Member Author

akovari commented Nov 19, 2019

@kurobako I updated this with what I'm thinking could be done pretty quickly...

@kurobako
Copy link
Contributor

I am not sure if I like (foo, bar) syntax since it looks like a tuple (yes it is, but element indices are different since first one is the symbol. Can we use something else instead? { } are free iirc, wdyt?

@akovari akovari added this to the alpha release milestone Jan 26, 2020
@akovari akovari self-assigned this Feb 9, 2020
akovari added a commit that referenced this issue Feb 15, 2020
akovari added a commit that referenced this issue Feb 15, 2020
akovari added a commit that referenced this issue Feb 16, 2020
akovari added a commit that referenced this issue Feb 18, 2020
@akovari akovari closed this as completed Feb 18, 2020
@akovari akovari reopened this Feb 18, 2020
akovari added a commit that referenced this issue Feb 23, 2020
@akovari akovari closed this as completed Feb 23, 2020
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