Skip to content

Lifetime Boundaries #411

Answered by TodePond
GoldenStack asked this question in Q&A
Sep 24, 2023 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Variables are scoped to their scope. In production, it would print this:

union a() {
    print(x
}

union b() {
    const const x<-50> = 2!
}

union c() {
    const const x<-50> = 3!
}

a()! // "x"
b()! 
a()! // "x"
c()!
a()! // "x"

Numbers are passed by value:

union a(b) {
    print(b)!
    print(b)!
}

const const x<2> = 2!
a(x)! // 2, 2
print(x)! // 2
print(x)! // "x"

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@GoldenStack
Comment options

Answer selected by GoldenStack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #408 on September 27, 2023 04:11.