[Issue 11929] Disallow `ref` in front tuple expansion in foreach over range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 15 07:25:08 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11929



--- Comment #3 from Maxim Fomin <maxim at maxim-fomin.ru> 2014-01-15 07:25:04 PST ---
(In reply to comment #2)
>
> Ranges of tuples generally contains generated somehow based on source ranges
> tuples (e.g. `zip` and `group`) so access to tuple elements by `ref` is a
> nonsense. As D type system doesn't provide head const I see no way to mark
> tuple elements non-`ref`able so I suggest to disallow such access in general as
> I'm not aware of cases where such functionality is needed. And even if there
> are such cases IHO its support doesn't worth potential confusion.

I still don't understand the scope of proposed limitation. Foreach over ranges
or foreach in general?

By the way, what you are asking can be reformulated as:

void foo(ref int i) { i = 0; }

void main()
{
   int i = 1;
   i.foo(); //oops, i = 0, let's ban ref attribute in function parameters
}

Why one should put 'ref' (supposedly unconsciously?) and then complain about
it?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list