scope for array parameters

Timon Gehr timon.gehr at gmx.ch
Wed Sep 5 04:56:42 PDT 2012


On 09/05/2012 01:50 AM, bearophile wrote:
> Jonathan M Davis:
>
>> That's part of why I keep saying not to use in whenever it comes up.
>> scope is
>> very broken, so in is very broken. And honestly, given how often
>> arrays are
>> used in structs, I suspect that it's not at all uncommon for in to be
>> used incorrectly.
>
> The situation with "in"/"scope" is worse than just deprecated stuff like
> "delete" or "typedef". I know those things are going away, so I don't
> use them, and this avoids the problem.
>
>
>> I believe that the only case that
>> has _any_ protection at all with scope right now is delegates, which
>> almost never should be const.
>
> Do you mean code like this? What's bad about this?
> My delegate arguments
> /function pointer arguments are usually const.
>
> void foo(const int delegate(int) dg) {}
> void main() {
>      foo((int x) => x);
> }
>
> Bye,
> bearophile

Similar code is the main reason for the hole in the const system.
Some people want that fixed, ergo it might break.


More information about the Digitalmars-d mailing list