[Issue 3008] Members of non-lvalues (rvalues) can be assigned to.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 30 14:16:01 PDT 2009


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





--- Comment #20 from Chad Joan <chadjoan at gmail.com>  2009-07-30 14:16:00 PDT ---
(In reply to comment #18)
> (In reply to comment #15)
> > Incorrect.
> > 
> > s is an lvalue (it isn't being returned)
> > s.getValue is an lvalue (pointer to some C's data, AKA a reference type)
> 
> *struct* MyNiftyPointerTo(T)
> 
> ...
> 
> MyNiftyPointerTo!(C) getValue()
> 
> Read that carefully about 5 times
> 
> getValue returns a struct.  getValue returns an rvalue.  Please recognize this
> before commenting again.
> 
> > It's not going away because MyNiftyPointerTo!(C).getValue is an lvalue.
> 
> MyNiftyPointerTo!(C) does not have a function called getValue, it is the return
> type from getValue
> 
> > But I'm going to answer the question anyways ...
> 
> Incidentally, I can type quite fast and I have never EVER wanted to save
> keystrokes when it sacrifices clarity.  My protests have nothing to do with
> saving keystrokes, they have to do with generic code -- writing code that works
> whether something is a builtin or a custom wrapper type.

(In reply to comment #18)
> (In reply to comment #15)
> > Incorrect.
> > 
> > s is an lvalue (it isn't being returned)
> > s.getValue is an lvalue (pointer to some C's data, AKA a reference type)
> 
> *struct* MyNiftyPointerTo(T)
> 
> ...
> 
> MyNiftyPointerTo!(C) getValue()
> 
> Read that carefully about 5 times
> 
> getValue returns a struct.  getValue returns an rvalue.  Please recognize this
> before commenting again.
> 
> > It's not going away because MyNiftyPointerTo!(C).getValue is an lvalue.
> 
> MyNiftyPointerTo!(C) does not have a function called getValue, it is the return
> type from getValue
> 

Ah, sorry.  I was confused because the meaning of getValue changed and foo was
never defined in MyNiftyPointerTo!(T).

> > But I'm going to answer the question anyways ...
> 
> Incidentally, I can type quite fast and I have never EVER wanted to save
> keystrokes when it sacrifices clarity.  My protests have nothing to do with
> saving keystrokes, they have to do with generic code -- writing code that works
> whether something is a builtin or a custom wrapper type.

So MyNiftyPointerTo!(T) may grab all of the compile-time reflection info from T
and forward all of its functions and such.  Then it becomes a reference to some
T, but not a reference in a sense the compiler knows about.  

I think I can see now where you're going with this.  

I suppose to really make everyone happy, there would need to be some way to
annotate struct definitions and say, "Hey, this thing can be mutated as an
rvalue, it's all under control."  That probably doesn't make Walter happy
though :(

Still, without any major change to the language, we can at least forbid the
assignment to members of rvalues as BCS suggested in comment #11, correct?

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