It may be useful to allow declaring variables without type

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 10 10:49:14 PDT 2015


On Wednesday, 10 June 2015 at 17:38:45 UTC, Binarydepth wrote:
> On Wednesday, 10 June 2015 at 17:32:18 UTC, Atila Neves wrote:
>> On Wednesday, 10 June 2015 at 17:04:20 UTC, Binarydepth wrote:
>>> I think that it could be useful to declare variables as 
>>> Python does and statically too in the same language. Just 
>>> make it's type when a value is assigned to the variable. This 
>>> could allow a program to adjust it's data types accordingly 
>>> to input when data is received from another program or an 
>>> user.
>>>
>>> BD
>>
>> I disagree on the usefulness. I think this is one of the few 
>> things Perl got right; the problem with automatically creating 
>> variables is that you might create one when you're not 
>> expecting to because of a typo.
>>
>> Atila
>
> Well, do think that can be solved by making the compiler report 
> unused variables ?
>
> BD

No, the problem is when you do use them, just not the ones you 
want.

Atila


More information about the Digitalmars-d mailing list