Automatic typing
deadalnix
deadalnix at gmail.com
Fri Jun 28 06:48:01 PDT 2013
On Friday, 28 June 2013 at 07:04:12 UTC, Jonathan M Davis wrote:
> On Friday, June 28, 2013 02:34:53 JS wrote:
>> Would it be possible for a language(specifically d) to have the
>> ability to automatically type a variable by looking at its use
>> cases without adding too much complexity? It seems to me that
>> most compilers already can infer type mismatchs which would
>> allow
>> them to handle stuff like:
>>
>> main()
>> {
>> auto x;
>> auto y;
>> x = 3; // x is an int, same as auto x = 3;
>> y = f(); // y is the same type as what f() returns
>> x = 3.9; // x is really a float, no mismatch with previous
>> type(int)
>> }
>>
>> in this case x and y's type is inferred from future use. The
>> compiler essentially just lazily infers the variable type.
>> Obviously ambiguity will generate an error.
>
> Regardless of whether such a feature would be of value (and
> honestly, I'm
> inclined to believe that it would do more harm than good),
> Walter would never
> go for it, because it would require code flow analysis, and he
> pretty much
> refuses to have that in the compiler or to have any feature
> which would
> require it in the language. So, while it may be technically
> feasible, it'll
> never happen.
>
code flow analysis is require for @disable this. And this is the
very reason why @disable this is full of holes right now.
More information about the Digitalmars-d
mailing list