Re: structs are now lvalues - what is with "auto ref"?

2013-01-21 Thread Namespace
It turns out there already was a pull request that does this: https://github.com/D-Programming-Language/dmd/pull/1019 If you are going to use code that is not merged yet, then maybe it's better to use that one (I've closed my pull request). Maybe you should reopen your pull, we need definitel

Re: structs are now lvalues - what is with "auto ref"?

2013-01-14 Thread Namespace
On Sunday, 13 January 2013 at 09:50:37 UTC, Namespace wrote: It turns out there already was a pull request that does this: https://github.com/D-Programming-Language/dmd/pull/1019 The pull request is still unmerged. Isn't this important enough or is the pull invalid? The question is still th

Re: structs are now lvalues - what is with "auto ref"?

2013-01-13 Thread Namespace
It turns out there already was a pull request that does this: https://github.com/D-Programming-Language/dmd/pull/1019 The pull request is still unmerged. Isn't this important enough or is the pull invalid?

Re: structs are now lvalues - what is with "auto ref"?

2013-01-03 Thread jerro
On Wednesday, 2 January 2013 at 01:05:09 UTC, Namespace wrote: Maybe it's best to just make a pull request and let others inspect the changes and discuss the semantics of auto ref. Or maybe it would be better to make a thread in digitalmars.D first? In my opinion you should do both, thread an

Re: structs are now lvalues - what is with "auto ref"?

2013-01-02 Thread jerro
In my opinion you should do both, thread and also pull request. I thank you again for your work. I'm using it already. I have opened a pull request now and replied to the thread about auto ref on digitalmars.D.

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread Namespace
Maybe it's best to just make a pull request and let others inspect the changes and discuss the semantics of auto ref. Or maybe it would be better to make a thread in digitalmars.D first? In my opinion you should do both, thread and also pull request. I thank you again for your work. I'm using

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread jerro
So it is ready to merge? I honestly don't know. I don't know enough about the DMD code base to be confident that there aren't some serious problems with my changes. Another problem is that it isn't entirely clear how auto ref is supposed to work. Should auto ref on templates work as it does

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread Namespace
I took over your changes into my current project (which isn't that small) and it works very well.

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread Namespace
On Tuesday, 1 January 2013 at 11:17:36 UTC, jerro wrote: On Tuesday, 1 January 2013 at 01:10:20 UTC, Namespace wrote: On Sunday, 30 December 2012 at 16:11:44 UTC, jerro wrote: On Sunday, 30 December 2012 at 16:00:22 UTC, Namespace wrote: Just hope for the best. Did you create a pull request?

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread jerro
On Tuesday, 1 January 2013 at 01:10:20 UTC, Namespace wrote: On Sunday, 30 December 2012 at 16:11:44 UTC, jerro wrote: On Sunday, 30 December 2012 at 16:00:22 UTC, Namespace wrote: Just hope for the best. Did you create a pull request? No. I need to first make it work correctly with const at

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread Era Scarecrow
On Tuesday, 1 January 2013 at 08:49:29 UTC, Era Scarecrow wrote: On Monday, 24 December 2012 at 19:09:35 UTC, Jonathan M Davis wrote: On Monday, December 24, 2012 20:03:24 monarch_dodra wrote: Snap. You got me. It wouldn't matter if the function accepted its argument by value. You'd still be

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread Era Scarecrow
On Monday, 24 December 2012 at 19:09:35 UTC, Jonathan M Davis wrote: On Monday, December 24, 2012 20:03:24 monarch_dodra wrote: Snap. You got me. It wouldn't matter if the function accepted its argument by value. You'd still be returning a reference to a variable that doesn't exist anymore.

Re: structs are now lvalues - what is with "auto ref"?

2012-12-31 Thread Namespace
On Sunday, 30 December 2012 at 16:11:44 UTC, jerro wrote: On Sunday, 30 December 2012 at 16:00:22 UTC, Namespace wrote: Just hope for the best. Did you create a pull request? No. I need to first make it work correctly with const at the very least. Sorry if I seem intrusive, but how does it

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread Namespace
On Sunday, 30 December 2012 at 16:11:44 UTC, jerro wrote: On Sunday, 30 December 2012 at 16:00:22 UTC, Namespace wrote: Just hope for the best. Did you create a pull request? No. I need to first make it work correctly with const at the very least. You should hurry up, it seems that Walter w

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread jerro
On Sunday, 30 December 2012 at 16:00:22 UTC, Namespace wrote: Just hope for the best. Did you create a pull request? No. I need to first make it work correctly with const at the very least.

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread Namespace
Just hope for the best. Did you create a pull request?

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread jerro
On Sunday, 30 December 2012 at 13:57:26 UTC, Namespace wrote: I've played with this a bit today. The code is at https://github.com/jerro/dmd/tree/auto-ref. I know next to nothing about DMD, so it could be all kinds of wrong, but it does at least seem to work. What do you think should happen i

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread Namespace
I've played with this a bit today. The code is at https://github.com/jerro/dmd/tree/auto-ref. I know next to nothing about DMD, so it could be all kinds of wrong, but it does at least seem to work. What do you think should happen in this case: void foo(auto ref int a){} void foo(int a){} ...

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread jerro
I'd love to see this fixed as well, but I can't change reality, and I have lots of other stuff that I need to do (much of which is Phobos-related) and not enough time to do it, so I'm not going to spend the time figuring out enough about the compiler to implement it myself. And the reality of t

Re: structs are now lvalues - what is with "auto ref"?

2012-12-29 Thread Jonathan M Davis
On Saturday, December 29, 2012 19:43:36 Minas Mina wrote: > So when it will be fixed I will be able to write: > > void foo(auto ref Vector3 v); > > and it will pass copies or references depending on the situation? For templated functions, it currently generates either void foo(ref Vector3 v);

Re: structs are now lvalues - what is with "auto ref"?

2012-12-29 Thread Namespace
On Saturday, 29 December 2012 at 18:43:37 UTC, Minas Mina wrote: So when it will be fixed I will be able to write: void foo(auto ref Vector3 v); and it will pass copies or references depending on the situation? Yes. The compiler generates the function for the specific situation. So you hav

Re: structs are now lvalues - what is with "auto ref"?

2012-12-29 Thread Minas Mina
So when it will be fixed I will be able to write: void foo(auto ref Vector3 v); and it will pass copies or references depending on the situation?

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Jonathan M Davis
On Friday, December 28, 2012 23:29:38 Namespace wrote: > Spontaneous question: why was the behavior altered from lvalue to > rvalue if there is still no replacement with "auto ref" and so a > lot of code becomes invalid? > I know of course that the change was necessary, but as long as > there is no

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Namespace
Spontaneous question: why was the behavior altered from lvalue to rvalue if there is still no replacement with "auto ref" and so a lot of code becomes invalid? I know of course that the change was necessary, but as long as there is no fix I don't understand such ruthless change. It meant no off

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Jonathan M Davis
On Friday, December 28, 2012 22:21:09 Namespace wrote: > > 2.061 is beta. I think that the chances of it having something > > like this in it > > are very close to zero. > > > > - Jonathan M Davis > > You know how to give a suffering hope. :D LOL. Yeah, well. It's not like I'm going to lie about

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Namespace
2.061 is beta. I think that the chances of it having something like this in it are very close to zero. - Jonathan M Davis You know how to give a suffering hope. :D

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Jonathan M Davis
On Friday, December 28, 2012 13:19:01 Namespace wrote: > In consideration that Andrei said that the implementation of > "auto ref" for none-template functions are relatively easy and > that until now only the first beta of 2.061 came out: How likely > is it that "auto ref" will implemented in this

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Namespace
I wrote a workaround for me: I implement it in Romulus. So for these functions: [code] void foo(auto ref const Foo f) { // do something with f } const(int[42]) bar(auto ref const Foo a, auto ref const Foo b) pure nothrow { // do something with a and b } const(int[42]) quatz(a

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Minas Mina
On Friday, 28 December 2012 at 12:47:03 UTC, Namespace wrote: On Friday, 28 December 2012 at 12:28:01 UTC, bearophile wrote: Namespace: How likely is it that "auto ref" will implemented in this release? Walter wants to release 2.061 "soon". So maybe that's for the successive (unstable?) ver

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Namespace
On Friday, 28 December 2012 at 12:28:01 UTC, bearophile wrote: Namespace: How likely is it that "auto ref" will implemented in this release? Walter wants to release 2.061 "soon". So maybe that's for the successive (unstable?) version of the compiler. Bye, bearophile As long as it is impl

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread bearophile
Namespace: How likely is it that "auto ref" will implemented in this release? Walter wants to release 2.061 "soon". So maybe that's for the successive (unstable?) version of the compiler. Bye, bearophile

Re: structs are now lvalues - what is with "auto ref"?

2012-12-28 Thread Namespace
In consideration that Andrei said that the implementation of "auto ref" for none-template functions are relatively easy and that until now only the first beta of 2.061 came out: How likely is it that "auto ref" will implemented in this release? Maybe an official statement would be good. Purel

Re: structs are now lvalues - what is with "auto ref"?

2012-12-26 Thread Namespace
On Wednesday, 26 December 2012 at 22:33:38 UTC, Jonathan M Davis wrote: On Wednesday, December 26, 2012 10:43:53 Namespace wrote: Quick question: what is the state of things with dmd 2.061 AFAIK, it's exactly the same as it was in 2.060. - Jonathan M Davis I mean, when it comes out. But tha

Re: structs are now lvalues - what is with "auto ref"?

2012-12-26 Thread Jonathan M Davis
On Wednesday, December 26, 2012 10:43:53 Namespace wrote: > Quick question: what is the state of things with dmd 2.061 AFAIK, it's exactly the same as it was in 2.060. - Jonathan M Davis

Re: structs are now lvalues - what is with "auto ref"?

2012-12-26 Thread Namespace
Quick question: what is the state of things with dmd 2.061 and I see that right, that "auto ref" is more complicated than first thought? :/

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 16:08:36 Andrei Alexandrescu wrote: > On 12/24/12 1:49 PM, Jonathan M Davis wrote: > > On Monday, December 24, 2012 13:45:10 Andrei Alexandrescu wrote: > Actually D's rules are different from C++'s in that regard; Walter > mentioned D is more sanguine about destroying d

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Andrei Alexandrescu
On 12/24/12 2:46 PM, anonymous wrote: On Monday, 24 December 2012 at 18:50:12 UTC, Jonathan M Davis wrote: const int& i = foo(bar(min(5, 7))); which would allow a reference to be kept around, which D disallows. Does it? const(int)* i = &foo(bar(min(5, 7))); We plan to forbid that. Andrei

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Andrei Alexandrescu
On 12/24/12 1:49 PM, Jonathan M Davis wrote: On Monday, December 24, 2012 13:45:10 Andrei Alexandrescu wrote: The very binding of rvalues to const ref would allow that breakage. We can't allow that to happen. But it's only bound for the length of the statement. After that, the binding can no l

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 21:42:09 monarch_dodra wrote: > Side question, is this legal? > > "int a = min(min(1,2), min(3,4));" > > How long do those temps last? I like this piece of code, because > the previous had that fishy "const int&", which raises eyebrows, > but I think this example coul

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread monarch_dodra
On Monday, 24 December 2012 at 19:09:35 UTC, Jonathan M Davis wrote: On Monday, December 24, 2012 20:03:24 monarch_dodra wrote: Hum... Indeed, it takes by ref *and* returns by ref. Passing in to out a const ref is *the* smoking gun. Working with D has gotten me used to functions that take by val

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 20:46:00 anonymous wrote: > On Monday, 24 December 2012 at 18:50:12 UTC, Jonathan M Davis > > wrote: > > const int& i = foo(bar(min(5, 7))); > > > > which would allow a reference to be kept around, which D > > disallows. > > Does it? > > const(int)* i = &foo(bar(min

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread anonymous
On Monday, 24 December 2012 at 18:50:12 UTC, Jonathan M Davis wrote: const int& i = foo(bar(min(5, 7))); which would allow a reference to be kept around, which D disallows. Does it? const(int)* i = &foo(bar(min(5, 7)));

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 20:03:24 monarch_dodra wrote: > Hum... Indeed, it takes by ref *and* returns by ref. Passing in > to out a const ref is *the* smoking gun. Working with D has > gotten me used to functions that take by value and return by > value... > > Snap. You got me. It wouldn't ma

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread monarch_dodra
On Monday, 24 December 2012 at 18:42:31 UTC, Andrei Alexandrescu wrote: On 12/24/12 1:05 PM, monarch_dodra wrote: On Monday, 24 December 2012 at 17:37:54 UTC, Andrei Alexandrescu wrote: On 12/24/12 12:11 PM, Jonathan M Davis wrote: On Monday, December 24, 2012 17:55:23 Minas Mina wrote: On Sun

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 19:05:32 monarch_dodra wrote: > On Monday, 24 December 2012 at 17:37:54 UTC, Andrei Alexandrescu > wrote: > > An important smoking gun is C++'s min(), which is allows > > writing unsafe code without casts. > > > > const int& haveANiceDay = min(4, 5); > > > > > > Andr

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 13:45:10 Andrei Alexandrescu wrote: > The very binding of rvalues to const ref would allow that breakage. We > can't allow that to happen. But it's only bound for the length of the statement. After that, the binding can no longer exist (as the binding was a function p

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Andrei Alexandrescu
On 12/24/12 1:20 PM, Jonathan M Davis wrote: On Monday, December 24, 2012 22:11:58 Dmitry Olshansky wrote: 12/24/2012 9:57 PM, Jonathan M Davis пишет: On Monday, December 24, 2012 12:37:54 Andrei Alexandrescu wrote: An important smoking gun is C++'s min(), which is allows writing unsafe code w

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Andrei Alexandrescu
On 12/24/12 12:57 PM, Jonathan M Davis wrote: On Monday, December 24, 2012 12:37:54 Andrei Alexandrescu wrote: An important smoking gun is C++'s min(), which is allows writing unsafe code without casts. const int& haveANiceDay = min(4, 5); But what does that have to do with const& for funct

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Andrei Alexandrescu
On 12/24/12 1:05 PM, monarch_dodra wrote: On Monday, 24 December 2012 at 17:37:54 UTC, Andrei Alexandrescu wrote: On 12/24/12 12:11 PM, Jonathan M Davis wrote: On Monday, December 24, 2012 17:55:23 Minas Mina wrote: On Sunday, 23 December 2012 at 23:59:55 UTC, Jonathan M Davis wrote: On Mond

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 22:11:58 Dmitry Olshansky wrote: > 12/24/2012 9:57 PM, Jonathan M Davis пишет: > > On Monday, December 24, 2012 12:37:54 Andrei Alexandrescu wrote: > >> An important smoking gun is C++'s min(), which is allows writing unsafe > >> code without casts. > >> > >> const int

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Dmitry Olshansky
12/24/2012 9:57 PM, Jonathan M Davis пишет: On Monday, December 24, 2012 12:37:54 Andrei Alexandrescu wrote: An important smoking gun is C++'s min(), which is allows writing unsafe code without casts. const int& haveANiceDay = min(4, 5); But what does that have to do with const& for function

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread monarch_dodra
On Monday, 24 December 2012 at 17:37:54 UTC, Andrei Alexandrescu wrote: On 12/24/12 12:11 PM, Jonathan M Davis wrote: On Monday, December 24, 2012 17:55:23 Minas Mina wrote: On Sunday, 23 December 2012 at 23:59:55 UTC, Jonathan M Davis wrote: On Monday, December 24, 2012 00:48:01 Namespace wr

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 12:37:54 Andrei Alexandrescu wrote: > An important smoking gun is C++'s min(), which is allows writing unsafe > code without casts. > > const int& haveANiceDay = min(4, 5); But what does that have to do with const& for function parameters? I can agree that it's bad f

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Andrei Alexandrescu
On 12/24/12 12:11 PM, Jonathan M Davis wrote: On Monday, December 24, 2012 17:55:23 Minas Mina wrote: On Sunday, 23 December 2012 at 23:59:55 UTC, Jonathan M Davis wrote: On Monday, December 24, 2012 00:48:01 Namespace wrote: but Andrei is dead set against - Jonathan M Davis Why? He's con

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 17:55:23 Minas Mina wrote: > On Sunday, 23 December 2012 at 23:59:55 UTC, Jonathan M Davis > > wrote: > > On Monday, December 24, 2012 00:48:01 Namespace wrote: > >but Andrei is dead set against > > > > - Jonathan M Davis > > Why? He's convinced that it's caused prob

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Minas Mina
On Sunday, 23 December 2012 at 23:59:55 UTC, Jonathan M Davis wrote: On Monday, December 24, 2012 00:48:01 Namespace wrote: but Andrei is dead set against - Jonathan M Davis Why?

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 12:16:15 Namespace wrote: > Put another way: how long will we probably still wait for a > solution? Yet another release, or 2? Say, 6 months or even > longer? When it comes in the near future (ie a maximum of 1-2 > months), then it would be sufficient simply to templati

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 14:01:10 Namespace wrote: > One more thing: Which pull request is for "auto ref" for > none-template functions? There isn't one. - Jonathan M Davis

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Namespace
One more thing: Which pull request is for "auto ref" for none-template functions?

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Namespace
Put another way: how long will we probably still wait for a solution? Yet another release, or 2? Say, 6 months or even longer? When it comes in the near future (ie a maximum of 1-2 months), then it would be sufficient simply to templatize my methods. But if it goes for much longer (which I stro

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Jonathan M Davis
On Monday, December 24, 2012 09:08:09 Namespace wrote: > Yes that's what I thought. My question was, if it's bad if now a > lot of my functions/methods are templatized. That would depend on what you're doing. It's a problem with classes, because templated functions can't be virtual. With everythi

Re: structs are now lvalues - what is with "auto ref"?

2012-12-24 Thread Namespace
Yes that's what I thought. My question was, if it's bad if now a lot of my functions/methods are templatized.

Re: structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Jonathan M Davis
On Monday, December 24, 2012 02:41:41 Namespace wrote: > > Plenty of people are using it with the problems that it > > currently has > > But how long? > > For the moment (or the next 2, 3 releases) it should be enough if > I write > void foo()(auto ref const Foo f) { > instead of > void foo(ref c

Re: structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Namespace
Plenty of people are using it with the problems that it currently has But how long? For the moment (or the next 2, 3 releases) it should be enough if I write void foo()(auto ref const Foo f) { instead of void foo(ref const Foo f) { or is there any difficulty? After all it's a template now.

Re: structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Jonathan M Davis
On Monday, December 24, 2012 01:19:22 Namespace wrote: > If I remember correctly, the discussion and the fix of "auto ref" > permanently on dmd since 2.058. But since at least June 2012. Is > that correct? It's been discussed off and on for ages, but it's never been a high enough priority to actu

Re: structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Namespace
If I remember correctly, the discussion and the fix of "auto ref" permanently on dmd since 2.058. But since at least June 2012. Is that correct? That is a very important use case. No one can/will use D seriously if D has all the time such big problems.

Re: structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Jonathan M Davis
On Monday, December 24, 2012 00:48:01 Namespace wrote: > As the title says: In dmd 2.061 structs are lvalues now, but we > have still no auto ref for none template functions. What should I > do if I need something like that and don't want to write a ref > and a none-ref function? > I'm very afraid

Re: structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Andrej Mitrovic
On 12/24/12, Namespace wrote: > As the title says: In dmd 2.061 structs are lvalues now You mean struct literals? They're rvalues now, this wasn't enforced before but it is now since a recent pull. Can't answer your other question, sorry.

structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Namespace
As the title says: In dmd 2.061 structs are lvalues now, but we have still no auto ref for none template functions. What should I do if I need something like that and don't want to write a ref and a none-ref function? I'm very afraid that "auto ref" will also not work in 2.062 So what is the st