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

use let and var to declare class slots #792

Open
nikodemus opened this issue Jul 29, 2021 · 0 comments
Open

use let and var to declare class slots #792

nikodemus opened this issue Jul 29, 2021 · 0 comments
Labels
feature-lang Language or library feature syntax Syntax change or addition
Milestone

Comments

@nikodemus
Copy link
Owner

Let declares an immutable slot.

class Point { x y }
end

-->

class Point
    let x.
    let y.
end

Can define slots which use values from earlier slots. (Evaluated in context where there is no self, and slots are represented
by temporary variables -- object is always fully constructed)

class Page
    let url.
    let content = url fetch.
end

Var declares a mutable slot:

class Counter
    var value := 0
    method next
        value := value + 1!
@nikodemus nikodemus added feature-lang Language or library feature syntax Syntax change or addition labels Jul 29, 2021
@nikodemus nikodemus added this to the Foolang 0.3.0 milestone Jul 29, 2021
This was referenced Jul 29, 2021
@nikodemus nikodemus changed the title used let and var to declare class slots use let and var to declare class slots Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-lang Language or library feature syntax Syntax change or addition
Projects
None yet
Development

No branches or pull requests

1 participant