[Issue 7177] $ should forward to length by default

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 24 13:47:34 PDT 2013


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



--- Comment #48 from monarchdodra at gmail.com 2013-03-24 13:47:32 PDT ---
(In reply to comment #47)
> (In reply to comment #46)
> > (In reply to comment #44)
> > > 1. hasLength!T || isNarrowString!T, but T does not define a member opDollar.
> > 
> > this can be shortened to hasLength!T, all strings define $, they are arrays. 
> > The compiler shouldn't be trying to guess whether something is a narrow string
> > or not according to phobos (or maybe I read this too literally?)
> 
> Good point, thanks.
> 
> > The rest of this is not unreasonable, and aside from breaking current code
> > (albeit less common current code in a non-obvious way), this proposal misses
> > one situation:  you want to define .length, but NOT opDollar.  In this case,
> > @disable opDollar should be allowed (if it's not already) as monarchdodra
> > suggested.
> 
> Yah, I was thinking of private or @disable'd symbols as "defined". Good to
> clarify that.
> 
> @Kenji, shall we go for this?

I apologize, but this isn't clear to me. I understand the what/why of the goal,
but I don't understand the how? Is it the compiler that is translating $ to
length? Then if so, how does "hasLength!T" come into play?

Or are we doing this "via" the compiler as a workaround until we can implement
opDollar as non-member? (since you mentioned the possibility of allowing
non-member operators)

I'm sorry, I just want to fully understand which direction we are taking.

-- 
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