--- Comment #22 from Steven Schveighoffer <>  2009-07-31 
06:11:34 PDT ---
(In reply to comment #20)
> (In reply to comment #18)
> > > 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).

Yes, I probably could have made that clearer, but the type was supposed to be a
functional replacement for C in that it hooks all calls to the underlying type.

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

Yes.  That is a good way of explaining it.

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

Due to the nature of the problem, I don't think there's any way to solve it, as
it reduces to the halting problem as BCS says.  And limiting it makes the
language less powerful than languages that don't forbid it (such as C# and
C++).  Without this ability, it will be a sticking point for people who don't
want to convert :)  I think we can pick better battles.

However, annotating such structs might be OK.  I am unsure how often this
annoyance would surface, so I'm unsure how much annotation is required.  If you
have to annotate more than 25% of structs just to get them to work correctly,
then I don't think it's worth it.

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

Yes, I think that should solve quite a few mistakes that people often make,
such as the Widget/Rectangle error.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to