ideas about ranges
Steven Schveighoffer
schveiguy at yahoo.com
Fri May 22 13:45:45 PDT 2009
On Fri, 22 May 2009 16:40:55 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Steven Schveighoffer wrote:
>> ref accomplishes all of this, except you can't get at the underlying
>> pointer to do things like compare to null or rebind. Maybe we simply
>> need some new operators to get at the ref addresses.
>
> Defining null references has been on the table too. I wrote a paragraph
> about them and then deleted it in fear of major aggravation.
>
> There's no need for new syntax. We can easily define things such that
> you can return *null when a reference is expected and checking
> &(r.popNext()) is null to figure out what's happening. I think it's bad
> design though.
&(r.popNext()) still gets you back to pointer-land. Might as well return
a pointer.
Also, I don't even think this works, because you can either check for null
or get the data, but not both:
ref T t; // syntax error, no?
while(&(t = r.popNext()) !is null)
{
}
doesn't work because you're not rebinding t.
-Steve
More information about the Digitalmars-d
mailing list