Issue 3382 - [tdpl] Implement uniform function call syntax #582

merged 2 commits into from Mar 8, 2012


None yet

4 participants

9rnsr commented Dec 26, 2011

This pull contains a small lexer fix.
To allow 1.prop syntax, short floating point syntax (e.g. 1.f, 1.Li) are disallowed.

Supplemental change of Phobos: phobos/pull/#378

@WalterBright WalterBright commented on the diff Dec 26, 2011
@@ -6595,6 +6595,25 @@ void AssertExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
e = e->semantic(sc);
return e;
+ else if ((t1b->isTypeBasic() && t1b->ty != Tvoid) ||
+ t1b->ty == Tenum || t1b->ty == Tnull)
+ { /* If ident is not a valid property, rewrite:
+ * e1.ident
+ * as:
+ * .ident(e1)
+ */
WalterBright Dec 26, 2011 Member

I'm not sure what the justification is for this rewrite. And, of course, anything that uses gagging I'm very nervous about and want to avoid as much as possible.

9rnsr Dec 27, 2011 Member

I thought that "uniform" means all types of objects, not only array + user-defined types. Is it my mistake?
And yes, use gagging is ugly, but at least it works for array UFCS. I'd also like to reduce use of them in the future, but today it's difficult.

andralex Jan 21, 2012 Member

What does gagging mean?

Anyway, Kenji is right: uniform call syntax must apply to all types as a last resort. This has been agreed upon and consequently is part of TDPL.

It saves a lot of boilerplate, see dlang/phobos#365. Also a lot of code in std.container consists of forwarding and aliasing that implement a rich interface in terms of a simpler one.

To recap: if all attempts to resolve a.b(c) fail, the call should be rewritten as b(a, c) and retried. The symbol "b" is looked up with the normal rules, i.e. it could be found in a different module than a's, which allows a module to extend functionality of a type defined by another module.

9rnsr Jan 22, 2012 Member

In dmd source, "gagging" means that suppress any errors that raised in compilation.
In this case with x.prop, compiler will replace it to prop(x) with gagging errors that the fail of searching prop function/property from typeof(x), instead of raising them.

Thanks for comment, Andrei. Issue 662 is the report of UFCS with basic types.
I think you should write comment in both 3382 and 662.


Is there any way to just pull ff7e522?

9rnsr commented Dec 27, 2011

Is there any way to just pull ff7e522?

Opened a pull request contains just only ff7e522.

braddr commented Mar 2, 2012

This pull request seems to cause dmd to go into an infinite loop. Every platform stalls when it gets to this pull request. I'm going to put in a quick hack to the auto-tester to skip it until it's been fixed.

9rnsr commented Mar 3, 2012

Sorry, I close this pull temporary.

@9rnsr 9rnsr closed this Mar 3, 2012
@9rnsr 9rnsr reopened this Mar 3, 2012
9rnsr commented Mar 3, 2012


@WalterBright WalterBright merged commit b7742f7 into dlang:master Mar 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment