DMD can implicitly convert class pointer to the bool. Is it bug or terrible feature?

Craig Dillabaugh craig.dillabaugh at gmail.com
Mon Nov 25 03:44:34 PST 2013


On Monday, 25 November 2013 at 11:12:12 UTC, Maxim Fomin wrote:
> On Monday, 25 November 2013 at 11:07:01 UTC, ilya-stromberg 
> wrote:
>>> int my_gobal_var;
>>>
>>> .my_global_var = 7;
>>>
>>> Is it possible?
>>
>> Sorry if I didn't explain idea properly.
>>
>> We can force using `.` before global variables. Almost 
>> everybody agree that use global variables is bad idea, so 
>> additional symbol looks acceptable.
>
> And what to do with code already written? What exactly should 
> be said to people who have to maintain the code? Do you 
> volunteer to write a dmd/druntime/phobos pull?

One of the things I had in mind with my idea at least, was that 
it could be introduced without breaking code, and would simply be 
a global scope (namespace) that folks could use to store their 
global variables. It would provide some additional safety/clarity 
for projects that wanted it.

Perhaps it could be implemented as a library (although that would 
likely preclude the exact syntax I showed). I don't feel I have 
the experience with D yet to implement such a thing. But maybe I 
will add it to my list of possible future projects.



More information about the Digitalmars-d mailing list