Feedback for the command syntax and the behavior of the temporary variable
Brian Goetz
brian.goetz at oracle.com
Mon Jun 29 18:49:17 UTC 2015
Agreed.
On 6/29/2015 11:35 AM, Robert Field wrote:
> My perspective is that the temp variables are scratch convenience
> variables, if users want to change them then it is there choice. I can
> easily see why a user might want to, for example, the user writes a
> method referencing a temp variables then realizes they want the temp to
> have a different value. In general, I am resistant to slapping the
> user's hand for what they choose to do unless there is a compelling reason.
>
> Why don't variable reference and assignment expressions generate a temp
> variables:
>
> x
>
> x = 1
>
> Because they already have a variable referring to the value. Adding a
> temp variables would be visual and conceptual noise. Much the same
> reason that:
>
> int x = 1
>
> does not generate a temp variables.
>
> -Robert
>
>
>
>
> On June 29, 2015 12:49:31 AM Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
>> On Jun 28, 2015, at 7:11 AM, ShinyaYoshida <bitterfoxc at gmail.com> wrote:
>> > 2. Opinion for the behavior of the temporary variable.
>> > His opinion is "Currently the temporary variable can be re-assigned,
>> but it
>> > doesn't make sense. It should be final.":
>> >
>> > -> 0
>> > | Expression value is: 0
>> > | assigned to temporary variable $1 of type int
>> >
>> > -> $1 = 10
>> > | Variable $1 has been assigned the value 10
>> >
>>
>> I was wondering about that too. So far i have persuaded myself this
>> behaviour is ok since it is not possible to have explicit `final`
>> variables:
>>
>> -> final int i = 0
>> | Warning:
>> | Modifier 'final' not permitted in top-level declarations, ignored
>> | final int i = 0;
>> | ^---^
>> | Added variable i of type int with initial value 0
>>
>>
>> I noticed another potential inconsistency:
>>
>> -> "foo"
>> | Expression value is: "foo"
>> | assigned to temporary variable $1 of type String
>>
>> -> int x = 1
>> | Added variable x of type int with initial value 1
>>
>> -> x
>> | Variable x of type int has value 1
>>
>> I was expecting x to be assigned to a temporary variable.
>>
>> Separately, it may not be that hard to support the following gIven the
>> support for assigning the value of an expression to a temporary variable:
>>
>> > x = 1
>> | Added variable x of type int with initial value 1
>>
>> Paul.
>
>
More information about the kulla-dev
mailing list