map kinds of Ranges

Jonathan M Davis jmdavisProg at gmx.com
Wed May 25 09:07:04 PDT 2011


On 2011-05-25 08:48, Steven Schveighoffer wrote:
> On Wed, 25 May 2011 11:45:30 -0400, Don <nospam at nospam.com> wrote:
> > Steven Schveighoffer wrote:
> >> On Wed, 25 May 2011 10:59:46 -0400, Don <nospam at nospam.com> wrote:
> >>> Robert Clipsham wrote:
> >>>> On 24/05/2011 04:28, Jonathan M Davis wrote:
> >>>>>> Thoughts on this?
> >>>>> 
> >>>>> I believe that the best and most likely to be implemented syntax
> >>>>> which has
> >>>>> been suggested (it was Andrei's idea IIRC) is to simply add optional
> >>>>> clauses
> >>>>> to attributes. So, instead of pure, you'd do pure(condition). If the
> >>>>> condition
> >>>>> is true, the templated function it's on is pure. If the condition is
> >>>>> false,
> >>>>> then the function isn't pure. Don't expect pure to become @pure or
> >>>>> nothrow to
> >>>>> become @nothrow though. I think that at this point, any attribute
> >>>>> which is a
> >>>>> keyword is going to stay one, and any attribute that has @ on the
> >>>>> front of it
> >>>>> is going to stay that way as well.
> >>>>> 
> >>>>> - Jonathan M Davis
> >>>>> 
> >>>>  Wouldn't it make sense to follow the same syntax as auto ref? auto
> >>>> 
> >>>> pure, auto nothrow, auto @safe etc? (Although I guess that doesn't
> >>>> allow for conditions, nevermind :<)
> >>> 
> >>> 'auto ref' is one of worst syntax anomalies in the language. It should
> >>> be a single keyword -- eg, 'autoref' -- it has nothing in common with
> >>> the other use of 'auto', and it's not necessarily 'ref'.
> >>> 
> >>  The current implementation is incorrect.  In a correct implementation
> >> 
> >> auto ref *is* always ref.
> >> 
> >>  -Steve
> > 
> > You're saying this example from the spec shouldn't compile?
> > 
> > auto ref foo()          { return 3; }  // value return
> 
> Yes.  Auto ref is specifically to allow passing rvalues as references to
> functions, not as a template that means either ref or not.  At least, that
> is my understanding from Andrei's description.  I don't have a copy of
> TDPL, but I think it's in there too.

From a quick glance at TDPL, I see no sign of it (or at least, none of the 
pages which the index claim to have auto or ref appear to mention it). My 
first reaction is to agree with Steve that auto ref must be a reference, but I 
vaguely recall a discussion about auto ref on a parameter meaning that the 
compiler then decided whether the parameter was a ref or not and that Andrei 
said that Walter had misunderstood the feature and misimplemented it. I don't 
recall the details though, so I could be wrong. Personally though, I would 
have expected auto ref as a return type to mean that the type was always a 
reference but that the type of that reference was inferred.

- Jonathan M Davis


More information about the Digitalmars-d mailing list