Handling constructive criticism
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Fri Apr 25 15:25:26 PDT 2008
Bill Baxter wrote:
> Bruno Medeiros wrote:
>> Sean Kelly wrote:
>>> etc. That said, the only compelling reasons for me to upgrade to 2.0
>>> are
>>> struct ctors and overload groups (or whatever they're called). The
>>> const
>>> syntax is a dis-incentive, as is the dual meaning of enum, dynamic
>>> closures, etc. They all complicate the syntax in undesirable ways or
>>> cause problems while attempting to solve solutions I don't need solved
>>> for the work I do.
>>
>> Huh? I understand the issues with const and enum, but what's the
>> problem with dynamic closures?
>
> The only problem is there's no way to turn it off now in the case that
> you were wanting a no-allocation delegate literal. I think the compiler
> tries to guess if allocating a closure is necessary, but it errs on the
> side of caution and so can create them when they aren't necessary.
>
> --bb
I've just read the relevant documentation, and there is no mention of
optimizations, it just says that "The stack variables referenced by a
nested function are still valid even after the function exits "
But I do recall a comment by Walter where he said the compiler would
only allocate such outer variables if it was really necessary. However,
like Sean mentioned, it's not safe to rely on such uncertain and
unguaranteed optimization if one wants to have the code optimized.
Perhaps one should be able to use 'scope' somehow to allow specifying
that a function/delegate should not escape the nested function. 'scope'
fits perfectly with that purpose, and it should work well with function
declarations, but with delegate literals it's another story... :S
--
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list