-
Notifications
You must be signed in to change notification settings - Fork 21
Clarification: By-name varargs unsupported #5787
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
Imported From: https://issues.scala-lang.org/browse/SI-5787?orig=1 |
@paulp said: I have asked martin for by-name + varargs before, the use case I often encounter being logging - I'd really like to be able to write def log(fmt: String, args: =>Any*) = if (logging) println(fmt.format(args: _*)) log("%s: %s %s", foo, bar, baz) A single instance could serve to hold all three (or N) methods, something like class AnonVarargs extends (Int => T) {
def apply(index: Int) = index match {
case 0 => foo
case 1 => bar
case 2 => baz
}
} There was some objection which I no longer remember. |
@lrytz said: |
@adriaanm said: |
@som-snytt said: |
@odersky said:
So it's clear they cannot be combined. |
@adriaanm said: |
@som-snytt said: |
@som-snytt said: |
@som-snytt said: |
@SethTisue said: |
closing as now out of scope for Scala 2 |
I just got that. |
To be fair, the guy who said that is known for sneaking in witticisms and puns that can go undetected for quite a while. |
This is edge-use-case, but:
Am I the only one who experiences a cognitive hiccup every time I have to disambiguate "named parameter" and "by-name parameter?" Internally (to myself), I've started calling (denoting) params that have call-by-name semantics "eval params" because of the loose notion that they are evaluated on reference. ("Deferred params" conveys the idea that evaluation is deferred, but people get confused about deferred to when, especially under partial application, and deferred doesn't suggest multiple evaluation. I hope Paul reads this and has a better word for it -- besides "evil params", of course.)
I haven't thought closely about this, except my terminology hangup, but the Seq[=>T] view might be a reason to ignore the use case.
The text was updated successfully, but these errors were encountered: