www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Why: error("multiple ! arguments are not allowed");

reply Adam D. Ruppe <destructionator gmail.com> writes:
Why is that prohibited? I just wrote

template foo(x) { template foo(y) {}}

and did

foo!(x)!y

and it triggered that error. If I comment that line and use the 
hacked dmd, it seems to work.


So why is that error there?
May 21
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Sunday, 21 May 2017 at 13:08:18 UTC, Adam D. Ruppe wrote:
 If I comment that line and use the hacked dmd, it seems to work.
Well, not exactly work, it didn't actually instantiate the inner template like it probably should have. So is it just not implemented correctly and became an error because y'all never got around to fixing the bugs, or is it prohibited by design? If so, why? Is it impossible to implement correctly?
May 21
prev sibling parent reply Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Sunday, 21 May 2017 at 13:08:18 UTC, Adam D. Ruppe wrote:
 foo!(x)!y
I think it's the same as foo!x!y. As for the reason - I think because the order is possibly ambiguous or something? You could interpret it as either (foo!x)!y or foo!(x!y).
May 21
parent reply Stanislav Blinov <stanislav.blinov gmail.com> writes:
On Sunday, 21 May 2017 at 13:42:50 UTC, Vladimir Panteleev wrote:
 On Sunday, 21 May 2017 at 13:08:18 UTC, Adam D. Ruppe wrote:
 foo!(x)!y
I think it's the same as foo!x!y. As for the reason - I think because the order is possibly ambiguous or something? You could interpret it as either (foo!x)!y or foo!(x!y).
I did encounter that a few times too, and my humble opinion is that there should not be any ambiguity, it should just be left-to-right, i.e.: foo!x!y is the same as (foo!x)!y, and foo!x!y!z!w would be (((foo!x)!y)!z)!w This is no different from foo!x.bar, which is (foo!x).bar and not foo!(x.bar) Allowing this will only help reduce boilerplate. If we do need different order, we could always explicitly instantiate beforehand.
May 21
parent Daniel N <no public.email> writes:
On Sunday, 21 May 2017 at 14:11:00 UTC, Stanislav Blinov wrote:
 On Sunday, 21 May 2017 at 13:42:50 UTC, Vladimir Panteleev 
 wrote:
 On Sunday, 21 May 2017 at 13:08:18 UTC, Adam D. Ruppe wrote:
 foo!(x)!y
I think it's the same as foo!x!y. As for the reason - I think because the order is possibly ambiguous or something? You could interpret it as either (foo!x)!y or foo!(x!y).
I did encounter that a few times too, and my humble opinion is that there should not be any ambiguity, it should just be left-to-right, i.e.: foo!x!y is the same as (foo!x)!y, and foo!x!y!z!w would be (((foo!x)!y)!z)!w This is no different from foo!x.bar, which is (foo!x).bar and not foo!(x.bar) Allowing this will only help reduce boilerplate. If we do need different order, we could always explicitly instantiate beforehand.
I ran into this aswell. Agreed, just an arbitrary restriction.
May 21