But, did you see that it's finding the implicit in B, not the one in A? You can delete the trait, extends and override and you get the same answer.
-
-
Ah, yes of course. I've minimized the example from a real case that happened at work, but it's not as minimal as I thought!
1 reply 0 retweets 0 likes -
I mean, val a: Int = a is even more minimal!
2 replies 0 retweets 2 likes -
Holy, does that compile? I thought implicit search was part of the issue
2 replies 0 retweets 1 like -
val a: Int = a, step-by-step: 1. First ask the JVM for an empty int-field 2. Now, calculate the value to set it to 3. Look up the value in the field, a; turns out it's 0 4. Save the result in the field, a
2 replies 1 retweet 4 likes -
Any reason why the compiler allows such a circular reference? It's seems pretty easy to catch, but I'm sure I'm missing the complications.
1 reply 0 retweets 2 likes -
Replying to @gabro27 @propensive
You'll have to ask the compiler engineers. There are some limited checks in place for similar situations: > def x: Int = x <console>:11: warning: method x does nothing other than call itself recursively
2 replies 0 retweets 1 like -
My assumption is that in the case of the trivial def, or the val which points at a stack frame, the compiler is faced with the immediate problem of what to compile this to, given there's nothing to compile.
2 replies 0 retweets 0 likes -
Replying to @propensive @gabro27
Hm? `def x = x` is a perfectly cromulent recursive definition. Local `val`, I agree.
1 reply 0 retweets 1 like -
I wish it were opt-in for the recursive definition, and the default were... name-shadowing (as I'm a big fan). Gimme: `val username = username.toLowerCase` please. So I don't have to call them username1, _username, or whatever.
2 replies 0 retweets 3 likes
I feel your pain. ;) I do use name shadowing quite frequently in for-comprehensions, and it's occasionally very useful. Only works for flapMaps, not maps, unfortunately.
-
-
How often do you use the recursive definition, in a val, in a method?
1 reply 0 retweets 1 like -
Do you mean the pointless, trivial version? I've used it twice already today! But basically never before. ;)
0 replies 0 retweets 1 like
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.