I mean, val a: Int = a is even more minimal!
-
-
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.
1 reply 0 retweets 1 like -
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. ;)
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.