-
Notifications
You must be signed in to change notification settings - Fork 13
"by" not described #74
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
Comments
That's not a keyword; it's an argument label; a mandatory part of the function call syntax. Any identifier works there; with this one it's called as |
That's fine, but I don't think it's described. Or maybe there are typos?
Here there is "by delta:" |
You use argument labels at call sites. For example: fun offset_let(_ v: let Vector2, by delta: let Vector2) -> Vector2 {
(x: v.x + delta.x, y: v.y + delta.y)
}
public fun main() {
let v = Vector2(x: 1, y: 1)
offset_let(v, by: Vector2(x: 2, y:, 0))
// ^^ here it is
} |
So you use the label at the call site and the argument name in the function? But they refer to the same argument? This needs some good description and explanation IMO. |
The label doesn't refer to anything, actually. It's just part of the syntax used in the function call, often used for clarifying words that distinguish the roles of the arguments when it is not identical to the parameter name, e.g. This comes directly from Swift, which see. The only difference is that Swift uses inconsistent rules for determining the implied argument label, when none is specified at the declaration site: for functions, it's the parameter name, but for subscripts and operators, it's |
The "Functions and methods" section has many examples using what seems to be a keyword "by" in arguments. I can find no place where this keyword is described, such as here preceding
delta
:The text was updated successfully, but these errors were encountered: