Jump to page: 1 24  
Page
Thread overview
Question about auto ref
Mar 15, 2013
Namespace
Mar 15, 2013
Namespace
Mar 15, 2013
Namespace
Mar 15, 2013
Jonathan M Davis
Mar 15, 2013
Namespace
Mar 16, 2013
Namespace
Mar 16, 2013
Jonathan M Davis
Mar 16, 2013
Namespace
Mar 25, 2013
Namespace
Mar 25, 2013
Jonathan M Davis
Mar 25, 2013
Namespace
Mar 25, 2013
Jonathan M Davis
Mar 25, 2013
Namespace
Mar 25, 2013
Namespace
Mar 26, 2013
Jonathan M Davis
Mar 26, 2013
Namespace
Mar 26, 2013
Namespace
Mar 26, 2013
Namespace
Mar 26, 2013
Jonathan M Davis
Mar 26, 2013
Timothee Cour
Mar 26, 2013
Jonathan M Davis
Mar 26, 2013
Minas Mina
Mar 26, 2013
Jonathan M Davis
Mar 27, 2013
Minas Mina
Mar 27, 2013
Namespace
Mar 27, 2013
Namespace
Mar 27, 2013
Namespace
Mar 29, 2013
Namespace
Mar 29, 2013
Martin Drasar
Mar 29, 2013
Namespace
Mar 26, 2013
Jonathan M Davis
Mar 27, 2013
Namespace
Mar 27, 2013
Namespace
March 15, 2013
In this thread:
http://forum.dlang.org/thread/mailman.2989.1356370854.5162.digitalmars-d@puremagic.com
Jonathan suggested that auto ref could work for non-template functions like this:
All parameters are declared as ref. For possible rvalues, ​​that are passed to this function, temporary variables are created.
Furthermore, Andrei said (http://forum.dlang.org/thread/mailman.2989.1356370854.5162.digitalmars-d@puremagic.com?page=2#post-kbcc62:24192v:242:40digitalmars.com) that this would work and would be very easy to implement.
As it is never happened and was not even suggested in other discussions anymore, there must be a reason why this is a bad idea.
Can anyone tell me why? Is it because ref is unsafe at this time? Or because 'auto ref' would work then different for non-template and template functions?
March 15, 2013
On Fri, 15 Mar 2013 11:54:27 -0400, Namespace <rswhite4@googlemail.com> wrote:

> In this thread:
> http://forum.dlang.org/thread/mailman.2989.1356370854.5162.digitalmars-d@puremagic.com
> Jonathan suggested that auto ref could work for non-template functions like this:
> All parameters are declared as ref. For possible rvalues, ​​that are passed to this function, temporary variables are created.
> Furthermore, Andrei said (http://forum.dlang.org/thread/mailman.2989.1356370854.5162.digitalmars-d@puremagic.com?page=2#post-kbcc62:24192v:242:40digitalmars.com) that this would work and would be very easy to implement.
> As it is never happened and was not even suggested in other discussions anymore, there must be a reason why this is a bad idea.
> Can anyone tell me why? Is it because ref is unsafe at this time? Or because 'auto ref' would work then different for non-template and template functions?

2 Simple reasons:  auto means "infer type", so using auto ref is confusing the meaning of auto.  For instance, auto ref could actually be valid as a return type (the auto is superfluous, but a valid storage class); Second, auto ref as currently implemented is useful, and using auto ref for its original intended meaning would nix that possibility.

Note, the concept itself is sound, it's just the keyword choice that is bad/confusing.

-Steve
March 15, 2013
But it works already for templates.
So if it's confusing, then, why was it introduced?
March 15, 2013
On Fri, 15 Mar 2013 12:32:35 -0400, Namespace <rswhite4@googlemail.com> wrote:

> But it works already for templates.
> So if it's confusing, then, why was it introduced?

The way it works for templates is to generate two separate functions, one which takes ref and one which takes by value.

The proposed auto ref would generate ONE function, and just generate a temporary lvalue for any rvalues passed to it.  Templates would not be required.

There are pros and cons for both implementations.

The reason it was introduced (and this is hearsay, I was not involved) is because Walter misunderstood the original intention.

-Steve
March 15, 2013
And it is planned to change the functionality of 'auto ref' to the proposed variant of Jonathan? Or was his proposal rejected?
March 15, 2013
On Fri, 15 Mar 2013 13:15:21 -0400, Namespace <rswhite4@googlemail.com> wrote:

> And it is planned to change the functionality of 'auto ref' to the proposed variant of Jonathan? Or was his proposal rejected?

I have no idea.  All I know is that Jonathan's proposal is really what Andrei wanted originally.

I think we need something like that, whether it's done via auto ref or not.

-Steve
March 15, 2013
On Friday, March 15, 2013 18:15:21 Namespace wrote:
> And it is planned to change the functionality of 'auto ref' to the proposed variant of Jonathan? Or was his proposal rejected?

I don't think that there was any official decision of any kind. IIRC, Kenji was looking into at one point and didn't want to use auto ref, because that would either mean changing it's meaning for templates (which would actually be a problem), or make it so that templated functions couldn't use the new scheme (which would also be a problem). I don't remember what attribute he was proposing for it though. I'd have to go digging to find out.

Basically, someone needs to implement it and then talk Walter into accepting it. That'll be easier for someone like Kenji, who's already a major contributor, but in theory, anyone can do it. It's just that there's a high risk that the pull request would languish for a while. And it would probably need to be implemented with a name other than auto ref in order to avoid the aforementioned problems, and having to agree on that could cause further delay.

- Jonathan M Davis
March 15, 2013
So first of all we have to find a new syntax/name?
AFAIK Kenji made ​​a pull request for a new implementation of 'auto ref' a few months ago. If that was already in the proposed manner of Jonathan, we need not to discuss with Walter, because the pull is open for months.
March 16, 2013
> Basically, someone needs to implement it and then talk Walter into accepting
> it. That'll be easier for someone like Kenji, who's already a major
> contributor, but in theory, anyone can do it.

Are there any tutorials or something similar, which make you a bit familiar with the compiler front-end?
Or you have to study the code to learn how it works?
March 16, 2013
On Saturday, March 16, 2013 14:41:37 Namespace wrote:
> > Basically, someone needs to implement it and then talk Walter
> > into accepting
> > it. That'll be easier for someone like Kenji, who's already a
> > major
> > contributor, but in theory, anyone can do it.
> 
> Are there any tutorials or something similar, which make you a
> bit familiar with the compiler front-end?
> Or you have to study the code to learn how it works?

The only thing I'm aware of which explains anything about the compiler outside of the compiler's code itself is this page here:

http://prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide

- Jonathan M Davis
« First   ‹ Prev
1 2 3 4