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

struct methods #7

Open
cqcallaw opened this issue Jan 2, 2016 · 0 comments
Open

struct methods #7

cqcallaw opened this issue Jan 2, 2016 · 0 comments

Comments

@cqcallaw
Copy link
Owner

cqcallaw commented Jan 2, 2016

Having a type

struct point {
    x:int
    y:int
}

and a function

translate:= (p:point, x_offset:int, y_offset:int) -> point {
    return p with { x = p.x + x_offset, y = p.y + y_offset }
}

It would be convenient and aligned with the language goal of succinctness to be able to write

p:= @Point with { x = 2, y = 3 }
p2:= p.translate(4, 5)
@cqcallaw cqcallaw changed the title Instance methods struct methods Jan 2, 2016
cqcallaw added a commit that referenced this issue May 13, 2016
…ions

This simple fix uncovered a very strange construct in test 5109 which I
believe to be incorrect; the variable `p` was referenceable before it was
fully defined.

There is obvious utility here in that it enables member functions
 (i.e. methods), but this implementation diverges from the plans outlined in
issue #7 and seems contrary to the project's philosophy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant