[Issue 7177] $ should forward to length by default

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 21 08:24:33 PDT 2013


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


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com


--- Comment #17 from Steven Schveighoffer <schveiguy at yahoo.com> 2013-03-21 08:24:32 PDT ---
(In reply to comment #16)
> The idea in comment #11 is interesting, but one problem point is that current
> compiler does not see UFCS fallback for operator overloading.

That is a deficiency that is easily worked around:

struct Concatable
{
   private string str;
   this(string str) {this.str = str;}
   string opBinary(string op)(string other) if (op == "+") {return str ~
other;}
}

Concatable c(string s) { return Concatable(s);}

auto s = "hello".c + "world";


> If we accept it, should we also accept this?
> 
> string opBinary(string op)(string s1, string s2) if (op == "+") {
>     return s1 ~ s2;
> }

Should we accept that this is now possible?  Sure, I don't see why not, it is
quite possible without additions to the language to make that a reality with a
tiny insignificant annoyance.  Should we accept string + string as a feature of
D/phobos?  No.

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


More information about the Digitalmars-d-bugs mailing list