You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should probably document that using clauses with parameters annotated val/var generate a given instance in their body (this is obvious for Scala 2 users, but maybe not for someone who has only ever seen the new syntax, where using may have been understood as only a "consumer" of given instances)
But this is also the case with contextual parameters on methods, and with contextual functions right? They also introduce a "given" in the corresponding scope. Retract...you are right .. it should be explained.
BUT, why does it generate a given instance? It seems completely surprising behavior to me. It would be much better to have an explicit declaration than to allow this, IMHO.
I donated some explanatory words which might be approximately correct and about in the right spot.
I remember there was a use case for export this.foo as bar, and extending that, export this.member as given T or something. But that is idle speculation.
I don't know that this is obvious for Scala 2 users. There are other gotchas around class parameters and aliasing, such as accidental shadowing, so maybe it's not completely surprising that some behaviors are completely surprising.
"it's not completely surprising that some behaviors are completely surprising" :) yes, one gets used to it with scala. Still, it's not the best quality of the language.
Uh oh!
There was an error while loading. Please reload this page.
We should probably document that
using
clauses with parameters annotatedval
/var
generate agiven
instance in their body (this is obvious for Scala 2 users, but maybe not for someone who has only ever seen the new syntax, whereusing
may have been understood as only a "consumer" ofgiven
instances)Minimized example
Output
23
The text was updated successfully, but these errors were encountered: