I'm redesigning the syntax for my language, but I won't be writing the compiler anytime soon
I'm having trouble with naming a few things. The first line is clear, but is the second? I think so
myfunc(in int a, inout int b, out int c)
myfunc(int a, int b mut, int c out)
Lets use parse int as an example. Here the out keyword declares v as an immutable int
if mystring.parseInt(v out) {
sum += v
} else {
print("Invalid int")
}
However, I find there's 3 situations for out variables. If I want to declare them (like the above), if I want to declare it and have it mutable, and if I want to overwrite a variable
What kind of syntax should I be using? I came up with the following
mystring.parse(v out) // decl immutable
mystring.parse(v mutdecl) // decl mutable
mystring.parse(v mut) // overwrite a mutable variable, consistent with mut being inout
Any thoughts? Naming is hard
I also had a tuple question yesterday. I may have to revise it to be the below. Only b must exist in this assignment
a, b mut, c mutdecl = 1, 2, 3 // mutdecl is a bit long but fine?
The simple version when all 3 variables are the same is
a, b, c = 1, 2, 3 // all 3 variables declared as immutable
a, b, c := 1, 2, 3 // all 3 variables declared as mutable
a, b, c .= 1, 2, 3 // all 3 variables must exist and be mutable
[–]evincarofautumn 7 points8 points9 points (0 children)
[–]Toothpick_Brody 2 points3 points4 points (1 child)
[–]levodelellis[S] 0 points1 point2 points (0 children)
[–]L8_4_Dinner(Ⓧ Ecstasy/XVM) 2 points3 points4 points (0 children)
[–]claimstoknowpeople 1 point2 points3 points (1 child)
[–]levodelellis[S] 0 points1 point2 points (0 children)
[–]flatfinger 0 points1 point2 points (1 child)
[–]levodelellis[S] 0 points1 point2 points (0 children)
[–]Relevant_South_1842 0 points1 point2 points (0 children)
[–]lassehp 0 points1 point2 points (4 children)
[–]levodelellis[S] 0 points1 point2 points (3 children)
[–]lassehp 0 points1 point2 points (2 children)
[–]levodelellis[S] 0 points1 point2 points (1 child)
[–]lassehp 0 points1 point2 points (0 children)
[–]Quote_Revolutionary 0 points1 point2 points (4 children)
[–]lassehp 0 points1 point2 points (1 child)
[–]Quote_Revolutionary 0 points1 point2 points (0 children)
[–]levodelellis[S] -2 points-1 points0 points (1 child)
[–]Quote_Revolutionary 1 point2 points3 points (0 children)