const debacle
Janice Caron
caron800 at googlemail.com
Wed Mar 26 10:18:56 PDT 2008
On 26/03/2008, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> "Janice Caron" wrote
>
> >I think I've got it.
>
> Janice, if you look closely, this follows EXACTLY my proposition in
> "Proposal for scoped const contracts", just substitute foo for inout :) But
> I'm glad we came to the same conclusion...
You're right!
I guess, as with all these things, it's not so much the syntax itself
that matters, as grokking what it all means. Sorry it took me so long.
> Other than that, this is exactly what I proposed and what I think should be
> implemented.
The question is, is our scheme simple enough. It won't fly if it
complicates the const system too much.
That said, there's not a great deal of difference in appearance,
between our scheme, and Walter's. For example, by omitting the
brackets, compare:
inout(T) f(inout T x);
with
T f(return T x);
They don't look that dissimilar. I think it might fly. Walter's scheme
isn't sufficiently expressive, and the declared return type is
counterintuitive. I think our scheme is better (though if Walter
wanted to call it return(T) instead of inout(T), I guess I could live
with that - as long as we get to keep everything else).
Another advantage of our scheme is, we get to use temporary values!
alias inout(char)[] iostring;
iostring f(iostring s)
{
iostring tmp = s[1..$];
return tmp;
}
So, what problem would you like to tackle next? :-)
(Joking)
More information about the Digitalmars-d
mailing list