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

Merged
merged 2 commits into from Mar 8, 2012

Conversation

Projects
None yet
4 participants
@9rnsr
Member

9rnsr commented Dec 26, 2011

http://d.puremagic.com/issues/show_bug.cgi?id=3382

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

+ * e1.ident
+ * as:
+ * .ident(e1)
+ */

This comment has been minimized.

@WalterBright

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.

@WalterBright

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.

This comment has been minimized.

@9rnsr

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.

@9rnsr

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.

This comment has been minimized.

@andralex

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 D-Programming-Language/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.

@andralex

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 D-Programming-Language/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.

This comment has been minimized.

@9rnsr

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.

@9rnsr

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.

@WalterBright

This comment has been minimized.

Show comment
Hide comment
@WalterBright

WalterBright Dec 26, 2011

Member

Is there any way to just pull ff7e522?

Member

WalterBright commented Dec 26, 2011

Is there any way to just pull ff7e522?

@9rnsr

This comment has been minimized.

Show comment
Hide comment
@9rnsr

9rnsr Dec 27, 2011

Member

Is there any way to just pull ff7e522?

Opened a pull request contains just only ff7e522.
D-Programming-Language#583

Member

9rnsr commented Dec 27, 2011

Is there any way to just pull ff7e522?

Opened a pull request contains just only ff7e522.
D-Programming-Language#583

@braddr

This comment has been minimized.

Show comment
Hide comment
@braddr

braddr Mar 2, 2012

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@9rnsr

9rnsr Mar 3, 2012

Member

Sorry, I close this pull temporary.

Member

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

This comment has been minimized.

Show comment
Hide comment
@9rnsr

9rnsr Mar 3, 2012

Member

Fixed.

Member

9rnsr commented Mar 3, 2012

Fixed.

WalterBright added a commit that referenced this pull request Mar 8, 2012

Merge pull request #582 from 9rnsr/fix3382_ufcs
Issue 3382 - [tdpl] Implement uniform function call syntax

@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