Thread overview
Re: support UFCS with fully qualified function names (was in "digitalmars.D.learn")
May 21, 2013
Kenji Hara
May 21, 2013
bearophile
May 21, 2013
If you need to use fully qualified name, you can use normal function call syntax.

    auto a = std.path.join("", "\n");

Kenji Hara

2013/5/21 Timothee Cour <thelastmammoth@gmail.com>

> (I've re-posting here upon request from bearophile, who seems to like it
> :) )
>
> I'd like to be able to use UFCS with fully qualified function names.
>
> A typical use case is to disambiguate , as in the following case:
>
> import std.path;
> import std.string;
> void main(){
>     //Error: std.path.join()(const(char)[] p1, const(char)[] p2, const(
> char[])[] more...) at ... conflicts with std.string.join at ...
>     auto a="".join("\n");
>     //what I'd like to have:
>     auto a="".(std.path.join)("\n");
> }
>
> note: the fact that std.path.join!().join is deprecated is irrelevant to
> this discussion.
>
> Any chance this could be supported?
>
> benefits:
> avoids breaking UFCS chains
>


May 21, 2013
Kenji Hara:

> If you need to use fully qualified name, you can use normal function call syntax.
>
>     auto a = std.path.join("", "\n");

I'm sure Timothee is aware of your solution, but it breaks UFCS chains or doesn't allow them.

So if you want to write:

foo.bar.baz.spam.red;

But you have to fully qualify baz, currently you have to write:

spam(std.somemodule.baz(foo.bar)).red;

Or more naturally:

auto aux = std.somemodule.baz(foo.bar);
aux.spam.red;

With Timothee idea you write something like:

foo.bar.(std.somemodule.baz).spam.red;

This looks like a small improvement.

(Elsewhere I have even suggested to optionally use typeof and assert with a dot-leading syntax, like sizeof).

Bye,
bearophile
May 21, 2013
On Tue, 21 May 2013 03:09:15 -0400, bearophile <bearophileHUGS@lycos.com> wrote:

> Kenji Hara:
>
>> If you need to use fully qualified name, you can use normal function call syntax.
>>
>>     auto a = std.path.join("", "\n");
>
> I'm sure Timothee is aware of your solution, but it breaks UFCS chains or doesn't allow them.
>
> So if you want to write:
>
> foo.bar.baz.spam.red;
>
> But you have to fully qualify baz, currently you have to write:
>
> spam(std.somemodule.baz(foo.bar)).red;
>
> Or more naturally:
>
> auto aux = std.somemodule.baz(foo.bar);
> aux.spam.red;
>
> With Timothee idea you write something like:
>
> foo.bar.(std.somemodule.baz).spam.red;
>
> This looks like a small improvement.
>
> (Elsewhere I have even suggested to optionally use typeof and assert with a dot-leading syntax, like sizeof).

Is it just me, or is this not trivially solved with import aliases?

-Steve