February 23, 2004
"Sean Kelly" <sean@ffwd.cx> wrote in message news:c1dfo4$2da7$1@digitaldaemon.com...
> Matthew wrote:
>
> > "Sean Kelly" <sean@ffwd.cx> wrote in message news:c0g9td$17gl$1@digitaldaemon.com...
> >
> >>I thought a bit more about this last night and decided the D way is good.  Adding const qualifiers for parameter passing would require the existence of const qualifiers for member functions, a mutable qualifier, etc.  And then there's the issue of some classes which just plain aren't copyable: streams and other complex objects with state information.
> >
> > Nooooooooooooooo! Don't believe the hype.
> >
> > It's bad, bad, bad. This is one important area in which the hunt for compiler simplicity is a specious one.
>
> I'll admit that I would like consts, but I can understand that it's far more than just adding a "const" qualifier to parameters.  but with "const" missing, I'd like to add a *strong* recommendation that creators of classes supply a copy ctor.
>
> > Everything is passed by value in Java, including references. A copy of a reference is another reference to the same object. Since the only distinguishing aspect of a refernece is its referent, it looks as if pass-by-reference is being used for references, but it's not. :-)
>
> But it amounts to the same thing.  This raises some interesting issues regarding exception safety and "const" gurantees.  Can a function writer ever be sure that an object he is passed will be returned in an unaltered state?  I'm inclined to think not, unless he always created a copy of any passed object before doing *anything* with it.  This is an idea I'm still warming up to.  I think I'll have to write some serious code in D before I decide whether this is an issue I'm happy with.

I am not bothered about the language absolutely preventing modification. In fact, I would disagree with that - the Spirit Of C, and all that.

All I want is that the programmer cannot alter a readonly variable without making some explicit (preferably ugly and greppable) construct, a la const_cast.

I don't need/want the language to try and detect such abuses. One can always abuse in any language. It's about "helping" the programmer to do correct work, rather than standing on his neck to make him do so, or not caring in the first place (which is the current situation).

But we're just hot-airing. This has been debated to death, and Walter's not buying.



1 2 3
Next ›   Last »