The type-inference does not work the same-way with fields and with local-vars. Is there a reason for this or is this a bug?
brianSun 27 Nov 2011
It is by design. We made a special exception for fields in ticket 986 so that all fields have an explicit type signature for readability. Everything else uses normal type inference rules.
MoOmSun 27 Nov 2011
Ok, I got it. Is there a reason why we don't apply the same special treatment for local-vars? I know I can use type-inference with local-vars but it would be more consistent if it would behave the same way.
brianSun 27 Nov 2011
Ok, I got it. Is there a reason why we don't apply the same special treatment for local-vars?
You don't need it in local variables because they support type inference. So I think it is better to have just have one way:
x := Str[,] // the one-way
Str[] x := [,] // if we supported both ways
Really it is a question of trade-offs: which is better to have one way versus two ways to use type inference in local variables, or to be consistent with fields?
MoOm Sat 26 Nov 2011
Consider the following sample-code:
When I run it, I get the following result:
The type-inference does not work the same-way with fields and with local-vars. Is there a reason for this or is this a bug?
brian Sun 27 Nov 2011
It is by design. We made a special exception for fields in ticket 986 so that all fields have an explicit type signature for readability. Everything else uses normal type inference rules.
MoOm Sun 27 Nov 2011
Ok, I got it. Is there a reason why we don't apply the same special treatment for local-vars? I know I can use type-inference with local-vars but it would be more consistent if it would behave the same way.
brian Sun 27 Nov 2011
You don't need it in local variables because they support type inference. So I think it is better to have just have one way:
Really it is a question of trade-offs: which is better to have one way versus two ways to use type inference in local variables, or to be consistent with fields?