[Issue 14838] [REG 2.066] Wrong attribute inference for auto-generated class destructor with static array of non-POD type

2015-07-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14838 --- Comment #2 from Martin Nowak c...@dawg.eu --- *** Issue 14839 has been marked as a duplicate of this issue. *** --

[Issue 14838] [REG 2.066] Wrong attribute inference for auto-generated class destructor with static array of non-POD type

2015-07-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14838 --- Comment #5 from Martin Nowak c...@dawg.eu --- And struct postblits. struct Array(T) { this(this) @safe {} } struct Test { Array!int[1] array; } bug2.d(2): Error: safe function 'bug2.Test.__fieldPostblit' cannot call system function

[Issue 14838] [REG 2.066] Wrong attribute inference for auto-generated class destructor with static array of non-POD type

2015-07-28 Thread via Digitalmars-d-bugs
||ag0ae...@gmail.com Summary|Wrong attribute inference |[REG 2.066] Wrong attribute |for auto-generated class|inference for |destructor with static |auto-generated class |array of non-POD type

[Issue 14838] New: Wrong attribute inference for auto-generated class destructor with static array of non-POD type

2015-07-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14838 Issue ID: 14838 Summary: Wrong attribute inference for auto-generated class destructor with static array of non-POD type Product: D Version: D2 Hardware: All OS

Re: with(auto x = ...)

2015-07-26 Thread Kapps via Digitalmars-d
On Friday, 24 July 2015 at 15:01:29 UTC, Adam D. Ruppe wrote: On Friday, 24 July 2015 at 14:48:30 UTC, Marc Schütz wrote: But I fail to see the relation to named parameters? You can make your parameters into a struct or tuple and fill them in with normal assignment. The with(auto) thing

Re: with(auto x = ...)

2015-07-26 Thread Idan Arye via Digitalmars-d
(with(ParameterTypeTuple!foo) { abc = 2, def = 3 }); Or just: auto args = with(ParameterTypeTuple!foo) { abc = 2, def = 3 }; foo(args); For initialization: auto a = with(new FooBar()) { name = Foo, bar = 3 }; Or: with(new Thread(foo) { isDaemon = true }).start(); Sadly it'll

[Issue 14381] It is too difficult to contribute to the auto-tester

2015-07-26 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14381 Mathias LANG pro.mathias.l...@gmail.com changed: What|Removed |Added Blocks|3031| --

Re: with(auto x = ...)

2015-07-26 Thread Timon Gehr via Digitalmars-d
find this one a bit ugly): foo(with(ParameterTypeTuple!foo) { abc = 2, def = 3 }); Or just: auto args = with(ParameterTypeTuple!foo) { abc = 2, def = 3 }; foo(args); For initialization: auto a = with(new FooBar()) { name = Foo, bar = 3 }; Or: with(new Thread(foo

[Issue 14381] It is too difficult to contribute to the auto-tester

2015-07-26 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14381 Mathias LANG pro.mathias.l...@gmail.com changed: What|Removed |Added Blocks||3031 --

Re: with(auto x = ...)

2015-07-26 Thread Idan Arye via Digitalmars-d
to make it an expression. For named parameters (admittedly, I find this one a bit ugly): foo(with(ParameterTypeTuple!foo) { abc = 2, def = 3 }); Or just: auto args = with(ParameterTypeTuple!foo) { abc = 2, def = 3 }; foo(args); For initialization: auto a = with(new FooBar

Re: with(auto x = ...)

2015-07-26 Thread Artur Skawina via Digitalmars-d
On 07/26/15 17:56, Idan Arye via Digitalmars-d wrote: On Sunday, 26 July 2015 at 14:49:40 UTC, Timon Gehr wrote: Well, no. That does not follow. We can have both a with statement and a with expression. Mmm... but how will we differ them? There's no need for that. (hint: mixin). But,

Re: with(auto x = ...)

2015-07-26 Thread Martin Nowak via Digitalmars-d
On 07/24/2015 05:01 PM, Adam D. Ruppe wrote: .ironically, given the other thread about statements as expressions where i said 'meh', this is actually a decent case for them too, to get the return value of foo out of that scope while still allowing auto. It would make sense to extend

Re: with(auto x = ...)

2015-07-25 Thread ketmar via Digitalmars-d
On Fri, 24 Jul 2015 14:12:39 +, Shammah Chancellor wrote: This operation doesn't seem to work. It would be a pretty handy thing to work since we don't support named parameters at this time. Comments? https://issues.dlang.org/show_bug.cgi?id=13526 signature.asc Description: PGP

with(auto x = ...)

2015-07-24 Thread Shammah Chancellor via Digitalmars-d
This operation doesn't seem to work. It would be a pretty handy thing to work since we don't support named parameters at this time. Comments?

Re: with(auto x = ...)

2015-07-24 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 24 July 2015 at 14:48:30 UTC, Marc Schütz wrote: But I fail to see the relation to named parameters? You can make your parameters into a struct or tuple and fill them in with normal assignment. The with(auto) thing will conveniently limit the scope of the temporary argument object

Re: with(auto x = ...)

2015-07-24 Thread via Digitalmars-d
On Friday, 24 July 2015 at 15:01:29 UTC, Adam D. Ruppe wrote: On Friday, 24 July 2015 at 14:48:30 UTC, Marc Schütz wrote: But I fail to see the relation to named parameters? You can make your parameters into a struct or tuple and fill them in with normal assignment. The with(auto) thing

Re: with(auto x = ...)

2015-07-24 Thread via Digitalmars-d
On Friday, 24 July 2015 at 14:12:39 UTC, Shammah Chancellor wrote: This operation doesn't seem to work. It would be a pretty handy thing to work since we don't support named parameters at this time. Comments? This limitation could probably be lifted easily. But I fail to see the relation

Re: Auto-Vectorization and array/vector operations

2015-07-18 Thread via Digitalmars-d
On Wednesday, 15 July 2015 at 22:42:05 UTC, Steven wrote: Does this mean that while compilers are expected to take advantage of them, they currently do not, even when they have proper alignment? I haven't tried LDC yet, so maybe LDC does perform auto-vectorization and I should attempt to use

Re: Auto-Vectorization and array/vector operations

2015-07-16 Thread Iain Buclaw via Digitalmars-d
On 16 July 2015 at 00:42, Steven via Digitalmars-d digitalmars-d@puremagic.com wrote: I was trying to show someone how awesome Dlang was earlier, and how the vector operations are expected to take advantage of the CPU vector instructions, and was dumbstruck when dmd and gdc both failed to auto

Re: Auto-Vectorization and array/vector operations

2015-07-16 Thread John Colvin via Digitalmars-d
On Wednesday, 15 July 2015 at 22:42:05 UTC, Steven wrote: I was trying to show someone how awesome Dlang was earlier, and how the vector operations are expected to take advantage of the CPU vector instructions, and was dumbstruck when dmd and gdc both failed to auto-vectorize a simple case

Auto-Vectorization and array/vector operations

2015-07-15 Thread Steven via Digitalmars-d
I was trying to show someone how awesome Dlang was earlier, and how the vector operations are expected to take advantage of the CPU vector instructions, and was dumbstruck when dmd and gdc both failed to auto-vectorize a simple case. I've stripped it down to the bare minimum and loaded

Re: Auto-Vectorization and array/vector operations

2015-07-15 Thread jmh530 via Digitalmars-d
On Wednesday, 15 July 2015 at 22:42:05 UTC, Steven wrote: I was trying to show someone how awesome Dlang was earlier, and how the vector operations are expected to take advantage of the CPU vector instructions, and was dumbstruck when dmd and gdc both failed to auto-vectorize a simple case

Re: auto ref is on the docket

2015-07-02 Thread ixid via Digitalmars-d
On Monday, 22 June 2015 at 04:11:41 UTC, Andrei Alexandrescu wrote: Walter and I discussed what auto ref for templates should look like and reached the conclusion that an approach based on lowering would be best. I added a proposed lowering to https://github.com/D-Programming-Language/dmd/pull

Re: auto ref is on the docket

2015-06-30 Thread via Digitalmars-d
On Sunday, 28 June 2015 at 13:08:48 UTC, rsw0x wrote: On Sunday, 28 June 2015 at 11:06:01 UTC, Marc Schütz wrote: On Sunday, 28 June 2015 at 07:36:41 UTC, Jonathan M Davis wrote: It makes no sense to pass rvalues by ref. The ref has to refer to a memory location so that a pointer can be passed

Re: auto ref is on the docket

2015-06-30 Thread kink via Digitalmars-d
if the type is big. So for efficiency, template auto-ref is a nice option, but requires a template and leads to code-bloat if both lvalues and rvalues are used as arguments. For these reasons, we want to have the additional option to pass both lvalues and rvalues by ref. Jonathan wants a non-templated

Re: auto ref is on the docket

2015-06-30 Thread Jonathan M Davis via Digitalmars-d
your POV the following would be an ideal situation (disregarding the need to avoid breaking changes): 1) `auto ref` for non-templates is required to make a function accept rvalue and lvalue refs alike. 2) `auto ref` for templates is changed to mean the same thing as 1). 3) `scope ref

Re: auto ref is on the docket

2015-06-30 Thread Daniel N via Digitalmars-d
This is semi-off-topic, but I was playing around... and line 12 broke my personal record for the most insane line ever written, maybe someone else finds it amusing also: [asm.dlang.org] http://goo.gl/ChdbwD

Re: auto ref is on the docket

2015-06-30 Thread Atila Neves via Digitalmars-d
(disregarding the need to avoid breaking changes): 1) `auto ref` for non-templates is required to make a function accept rvalue and lvalue refs alike. 2) `auto ref` for templates is changed to mean the same thing as 1). 3) `scope ref` prevents escaping of the reference. Neither of `auto ref

Re: auto ref is on the docket

2015-06-30 Thread Jonathan M Davis via Digitalmars-d
On Sunday, 28 June 2015 at 10:50:10 UTC, Marc Schütz wrote: Thank you Jonathan, I think I (like kinke in his post above) finally understand your stance. So I guess from your POV the following would be an ideal situation (disregarding the need to avoid breaking changes): 1) `auto ref` for non

Re: auto ref is on the docket

2015-06-30 Thread via Digitalmars-d
On Monday, 29 June 2015 at 17:19:48 UTC, Jonathan M Davis wrote: On Sunday, 28 June 2015 at 10:50:10 UTC, Marc Schütz wrote: The main problems with this is that they aren't in fact orthogonal: `auto ref` without `scope ref` almost only makes sense if you want to deliberately break something

Re: auto ref is on the docket

2015-06-28 Thread Temtaime via Digitalmars-d
All values must be passed by ref because otherwise it will be leading for code bloat : we want eliminate by having only one function that accepts both rvalues and lvalues.

Re: auto ref is on the docket

2015-06-28 Thread rsw0x via Digitalmars-d
On Sunday, 28 June 2015 at 11:06:01 UTC, Marc Schütz wrote: On Sunday, 28 June 2015 at 07:36:41 UTC, Jonathan M Davis wrote: It makes no sense to pass rvalues by ref. The ref has to refer to a memory location so that a pointer can be passed underneath the hood, and rvalues don't qualify for

Re: auto ref is on the docket

2015-06-28 Thread Jonathan M Davis via Digitalmars-d
On Sunday, 28 June 2015 at 05:46:11 UTC, Manu wrote: On 28 June 2015 at 08:50, Jonathan M Davis via Digitalmars-d digitalmars-d@puremagic.com wrote: [..] That's what auto ref was originally introduced to do. The reason that it works only with templates is because Walter misunderstood what

Re: auto ref is on the docket

2015-06-28 Thread via Digitalmars-d
Thank you Jonathan, I think I (like kinke in his post above) finally understand your stance. So I guess from your POV the following would be an ideal situation (disregarding the need to avoid breaking changes): 1) `auto ref` for non-templates is required to make a function accept rvalue

Re: auto ref is on the docket

2015-06-28 Thread via Digitalmars-d
On Sunday, 28 June 2015 at 07:36:41 UTC, Jonathan M Davis wrote: It makes no sense to pass rvalues by ref. The ref has to refer to a memory location so that a pointer can be passed underneath the hood, and rvalues don't qualify for that. I strongly disagree with that. This is an

Re: auto ref is on the docket

2015-06-27 Thread via Digitalmars-d
). That's a completely orthogonal issue to ref or auto ref. That's an @system operation (since taking the address of a local variable is @system), and it's up to you to not screw it up. scope might cover that if it were fully ironed out, since that does involve escaping, but it also might

Re: auto ref is on the docket

2015-06-27 Thread kinke via Digitalmars-d
On Saturday, 27 June 2015 at 11:10:49 UTC, Marc Schütz wrote: On Saturday, 27 June 2015 at 01:18:19 UTC, Jonathan M Davis wrote: That's a completely orthogonal issue to ref or auto ref. That's an @system operation (since taking the address of a local variable is @system), and it's up to you

Re: auto ref is on the docket

2015-06-27 Thread Jonathan M Davis via Digitalmars-d
) to fix this problem. So, with that, we eliminate the safety problem with ref itself, and we can safely have auto ref accept rvalues by having it assign them to a temporary variable first. Yes this is now possible, but why in all world do you want the keyword that enables it to be `auto ref

Re: auto ref is on the docket

2015-06-27 Thread Manu via Digitalmars-d
On 28 June 2015 at 08:50, Jonathan M Davis via Digitalmars-d digitalmars-d@puremagic.com wrote: [..] That's what auto ref was originally introduced to do. The reason that it works only with templates is because Walter misunderstood what Andrei was proposing. So, it makes sense to use

Re: auto ref is on the docket

2015-06-26 Thread Jonathan M Davis via Digitalmars-d
a pointer to a ref parameter somewhere outside (global/instance variable). That's a completely orthogonal issue to ref or auto ref. That's an @system operation (since taking the address of a local variable is @system), and it's up to you to not screw it up. scope might cover that if it were

Re: auto ref is on the docket

2015-06-26 Thread kinke via Digitalmars-d
))); // promote forwarded rvalue ref to lvalue S s3 = forward(S(3)); // let the lvalue escape and manipulate it indirectly auto state = new State(); state.initByEscaping(forward(s3)); // requires lvalue `ref`, forward() returns that for lvalue arg state.manipulate(); // GC

Re: auto ref is on the docket

2015-06-25 Thread kink via Digitalmars-d
a solution for rvalue refs for years, and, as you know, are waiting since then, as `auto ref` for templates alone is simply not enough. To quote Manu from the DIP36 thread: It is, without doubt, the single biggest complaint I've heard by virtually every programmer I've introduced D to. +1

Re: auto ref is on the docket

2015-06-25 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 25 June 2015 at 08:04:09 UTC, kink wrote: On Wednesday, 24 June 2015 at 23:30:53 UTC, Jonathan M Davis wrote: But this has _nothing_ to do with scope, and scope ref was already rejected. The whole point of this is support having a function accept both rvalues and lvalues, not to

Re: auto ref is on the docket

2015-06-25 Thread Jonathan M Davis via Digitalmars-d
to repeatedly convince Walter and Andrei to have scope ref do something similar to what we're talking about auto ref doing, Walter and Andrei repeatedly shot it down. They had no interest in having scope ref as any kind of special attribute. So, as of the beginning of May 2013 (which was less than

Re: auto ref is on the docket

2015-06-25 Thread Timon Gehr via Digitalmars-d
On 06/25/2015 10:28 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: trying to expand it with scope ref as if that were simply an extension of scope makes no sense. Before we can even consider what something like scope ref might mean, we'd have to properly define what scope means.

Re: auto ref is on the docket

2015-06-25 Thread via Digitalmars-d
On Wednesday, 24 June 2015 at 17:47:51 UTC, Namespace wrote: On Wednesday, 24 June 2015 at 17:45:15 UTC, Marc Schütz wrote: On Wednesday, 24 June 2015 at 09:54:01 UTC, Jonathan M Davis wrote: On Wednesday, 24 June 2015 at 09:26:49 UTC, Temtaime wrote: Simply give a possibility to ref in

Re: auto ref is on the docket

2015-06-25 Thread via Digitalmars-d
On Wednesday, 24 June 2015 at 23:30:53 UTC, Jonathan M Davis wrote: On Wednesday, 24 June 2015 at 16:39:22 UTC, kink wrote: On Wednesday, 24 June 2015 at 11:19:04 UTC, Jonathan M Davis wrote: [...] 3. Add a new attribute which does what's being proposed for auto ref for non-templated

Re: auto ref is on the docket

2015-06-24 Thread Iain Buclaw via Digitalmars-d
On 22 Jun 2015 08:40, Andrei Alexandrescu via Digitalmars-d digitalmars-d@puremagic.com wrote: On 6/21/15 11:31 PM, Andrei Alexandrescu wrote: On 6/21/15 10:25 PM, Walter Bright wrote: The idea is that fun(5) would be lowered to: auto tmp = 5; fun(tmp); I don't think

Re: auto ref is on the docket

2015-06-24 Thread Temtaime via Digitalmars-d
Simply give a possibility to ref in allowing use rvalues. Don't add any new strange attributes.

Re: auto ref is on the docket

2015-06-24 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, 24 June 2015 at 00:23:42 UTC, Timon Gehr wrote: On 06/23/2015 03:01 AM, Andrei Alexandrescu wrote: the perfect solution. We might as well do it right. Why promote unnecessary template bloat? I'm fine with it either way, but given all of the template bloat that auto ref

Re: auto ref is on the docket

2015-06-24 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, 23 June 2015 at 19:13:28 UTC, bitwise wrote: And I still think Timon's statement is untrue. There is a reason, which is that the new auto ref syntax forces reference parameters for all types(even primitives), where the old template approach does not. The old template approach

Re: auto ref is on the docket

2015-06-24 Thread Namespace via Digitalmars-d
On Wednesday, 24 June 2015 at 09:54:01 UTC, Jonathan M Davis wrote: On Wednesday, 24 June 2015 at 09:26:49 UTC, Temtaime wrote: Simply give a possibility to ref in allowing use rvalues. That has already been rejected. - Jonathan M Davis How many times did I say that already? :)

Re: auto ref is on the docket

2015-06-24 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, 24 June 2015 at 09:26:49 UTC, Temtaime wrote: Simply give a possibility to ref in allowing use rvalues. That has already been rejected. - Jonathan M Davis

Re: auto ref is on the docket

2015-06-24 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, 24 June 2015 at 10:02:12 UTC, Namespace wrote: On Wednesday, 24 June 2015 at 09:54:01 UTC, Jonathan M Davis wrote: On Wednesday, 24 June 2015 at 09:26:49 UTC, Temtaime wrote: Simply give a possibility to ref in allowing use rvalues. That has already been rejected. - Jonathan M

Re: auto ref is on the docket

2015-06-24 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, 24 June 2015 at 16:39:22 UTC, kink wrote: On Wednesday, 24 June 2015 at 11:19:04 UTC, Jonathan M Davis wrote: [...] 3. Add a new attribute which does what's being proposed for auto ref for non-templated functions, in which case, we can use the non-templated behavior

Re: auto ref is on the docket

2015-06-24 Thread kink via Digitalmars-d
On Wednesday, 24 June 2015 at 11:19:04 UTC, Jonathan M Davis wrote: [...] 3. Add a new attribute which does what's being proposed for auto ref for non-templated functions, in which case, we can use the non-templated behavior with templates as well and thus avoid template bloat when all you

Re: auto ref is on the docket

2015-06-24 Thread Iain Buclaw via Digitalmars-d
: On 6/21/15 10:25 PM, Walter Bright wrote: The idea is that fun(5) would be lowered to: auto tmp = 5; fun(tmp); I don't think that lowering is recommended - it prolongs the lifetime of the temporary through the end of the caller. But that may be actually a good thing

Re: auto ref is on the docket

2015-06-24 Thread Namespace via Digitalmars-d
On Wednesday, 24 June 2015 at 17:45:15 UTC, Marc Schütz wrote: On Wednesday, 24 June 2015 at 09:54:01 UTC, Jonathan M Davis wrote: On Wednesday, 24 June 2015 at 09:26:49 UTC, Temtaime wrote: Simply give a possibility to ref in allowing use rvalues. That has already been rejected. Then we

Re: auto ref is on the docket

2015-06-24 Thread via Digitalmars-d
to: auto tmp = 5; fun(tmp); I don't think that lowering is recommended - it prolongs the lifetime of the temporary through the end of the caller. But that may be actually a good thing. On second thought - Walter's lowering, which makes the rvalue last more than strictly necessary

Re: auto ref is on the docket

2015-06-24 Thread via Digitalmars-d
On Wednesday, 24 June 2015 at 09:54:01 UTC, Jonathan M Davis wrote: On Wednesday, 24 June 2015 at 09:26:49 UTC, Temtaime wrote: Simply give a possibility to ref in allowing use rvalues. That has already been rejected. Then we need to reconsider it. If that was several years ago, much has

Re: auto ref is on the docket

2015-06-23 Thread kink via Digitalmars-d
On Tuesday, 23 June 2015 at 09:57:26 UTC, Marc Schütz wrote: On Monday, 22 June 2015 at 19:05:28 UTC, kinke wrote: [...] To clarify: What I meant by my comment was that const-ness should not be a precondition for allowing rvalue refs. Mutable rvalue refs are fine. I know and see it the same

Re: auto ref is on the docket

2015-06-23 Thread Daniel N via Digitalmars-d
. auto is worse because, if you later decide you need to add a template parameter then the meaning is changed and you get a _hidden_ performance issue. Thus requiring neither auto nor const is the least evil of the above. You could always use comments, or even dummy aliases to make the code self

Re: auto ref is on the docket

2015-06-23 Thread Jonathan M Davis via Digitalmars-d
. - Jonathan M Davis Thus the solution cannot require const. auto is worse because, if you later decide you need to add a template parameter then the meaning is changed and you get a _hidden_ performance issue. And how does it introduce a hidden performance issue. You'd end up with some template

Re: auto ref is on the docket

2015-06-23 Thread via Digitalmars-d
On Tuesday, 23 June 2015 at 12:45:25 UTC, kink wrote: On Tuesday, 23 June 2015 at 09:57:26 UTC, Marc Schütz wrote: To guarantee this from the caller's POV, the callee must be pure and the parameters must be known not to alias each other. This is obviously true. Rvalues aren't affected as they

Re: auto ref is on the docket

2015-06-23 Thread John Colvin via Digitalmars-d
On Tuesday, 23 June 2015 at 16:27:34 UTC, Jonathan M Davis wrote: On Tuesday, 23 June 2015 at 13:52:19 UTC, Daniel N wrote: On Tuesday, 23 June 2015 at 11:03:10 UTC, Jonathan M Davis wrote: [...] Thus the solution cannot require const. auto is worse because, if you later decide you need

Re: auto ref is on the docket

2015-06-23 Thread bitwise via Digitalmars-d
. The two mechanisms shouldn't share the same syntax, because then there is no way to tell them apart for template functions. You would be losing the optimization of passing primitive types by value, wouldn't you? Not if you keep the current `auto ref` template syntax AND introduce

Re: auto ref is on the docket

2015-06-23 Thread bitwise via Digitalmars-d
On Mon, 22 Jun 2015 19:09:45 -0400, Timon Gehr timon.g...@gmx.ch wrote: There is no reason to prevent templates from using the mechanism that generates only one copy. The two mechanisms shouldn't share the same syntax, because then there is no way to tell them apart for template functions.

Re: auto ref is on the docket

2015-06-23 Thread kinke via Digitalmars-d
On Tuesday, 23 June 2015 at 19:13:28 UTC, bitwise wrote: And I still think Timon's statement is untrue. There is a reason, which is that the new auto ref syntax forces reference parameters for all types(even primitives), where the old template approach does not. Timon suggested using another

Re: auto ref is on the docket

2015-06-23 Thread kinke via Digitalmars-d
then there is no way to tell them apart for template functions. You would be losing the optimization of passing primitive types by value, wouldn't you? Not if you keep the current `auto ref` template syntax AND introduce another syntax `scope ref` for non-escapable references also accepting rvalues.

Re: auto ref is on the docket

2015-06-23 Thread Jonathan M Davis via Digitalmars-d
const. auto is worse because, if you later decide you need to add a template parameter then the meaning is changed and you get a _hidden_ performance issue. And how does it introduce a hidden performance issue. You'd end up with some template bloat, but that's it, and that's just going

Re: auto ref is on the docket

2015-06-23 Thread weaselcat via Digitalmars-d
On Tuesday, 23 June 2015 at 17:05:41 UTC, John Colvin wrote: On Tuesday, 23 June 2015 at 16:27:34 UTC, Jonathan M Davis wrote: On Tuesday, 23 June 2015 at 13:52:19 UTC, Daniel N wrote: [...] And how does it introduce a hidden performance issue. You'd end up with some template bloat, but

Re: auto ref is on the docket

2015-06-23 Thread via Digitalmars-d
On Monday, 22 June 2015 at 18:10:11 UTC, Andrei Alexandrescu wrote: On 6/22/15 9:54 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: `auto ref` without a working `scope` implementation is unsafe. I'm unclear on this. With the existence of the return attribute, what's unsafe about

Re: auto ref is on the docket

2015-06-23 Thread kink via Digitalmars-d
imho. As different behavior for templated `auto ref` and non-template `auto ref` seems to be an issue for more people here, why don't just rename the non-templated one `scope ref`, so that it's usable for templates too and also enables the `in ref` shortcut for const? I find `const auto ref

Re: auto ref is on the docket

2015-06-23 Thread via Digitalmars-d
On Monday, 22 June 2015 at 19:05:28 UTC, kinke wrote: On Monday, 22 June 2015 at 16:54:50 UTC, Marc Schütz wrote: With the difference that C++ requires const-ness. Yep, so `in ref T` translating to `scope const ref T` would be D's convenient and safe counterpart to C++' `const T`

Re: auto ref is on the docket

2015-06-23 Thread Daniel N via Digitalmars-d
On Tuesday, 23 June 2015 at 01:07:17 UTC, Jonathan M Davis wrote: No, you can't guarantee that an auto ref parameter won't be mutated, but auto ref clearly indicates that you intend to accept both lvalues and rvalues, meaning that it would be stupid to be writing the function with the idea

Re: auto ref is on the docket

2015-06-23 Thread Namespace via Digitalmars-d
them apart for template functions. I understand. For my money I'd be okay with what's being proposed instead of complicating the language yet again for the perfect solution. -- Andrei There is no perfect solution. :) Some are for in/scope ref, some are against it. Some are for auto ref, some

Re: auto ref is on the docket

2015-06-23 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, 23 June 2015 at 06:49:50 UTC, Daniel N wrote: On Tuesday, 23 June 2015 at 01:07:17 UTC, Jonathan M Davis wrote: No, you can't guarantee that an auto ref parameter won't be mutated, but auto ref clearly indicates that you intend to accept both lvalues and rvalues, meaning

Re: auto ref is on the docket

2015-06-23 Thread Timon Gehr via Digitalmars-d
On 06/23/2015 03:01 AM, Andrei Alexandrescu wrote: On 6/22/15 4:09 PM, Timon Gehr wrote: There is no reason to prevent templates from using the mechanism that generates only one copy. The two mechanisms shouldn't share the same syntax, because then there is no way to tell them apart for

Re: auto ref is on the docket

2015-06-22 Thread Namespace via Digitalmars-d
please let us concentrate and discuss how we could solve this problem with auto ref. :) To repeat my statement from the PR: I would also prefer to avoid the generation of further functions, because I want to avoid the code bloat. I like the way of the current implementation, because

Re: auto ref is on the docket

2015-06-22 Thread via Digitalmars-d
scope and escape analysis could do a better job is unclear and if you want to solve the problem this way you will wait a very long time. Not at all. `auto ref` without a working `scope` implementation is unsafe. If that is acceptable for now, then it should be just as acceptable to already use

Re: auto ref is on the docket

2015-06-22 Thread Namespace via Digitalmars-d
We had this discussion already with DIP 36. A PR still exists AFAIK, but because it was rejected I don't think that's going to happen. :) So auto ref is obviously the choice. If you insist on scope/in ref, please make your own thread and ask why it was rejected or read the corresponding thread.

Re: auto ref is on the docket

2015-06-22 Thread Andrei Alexandrescu via Digitalmars-d
On 6/22/15 3:04 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Just lower it to: { auto tmp = 5; fun(tmp); } You need to lower an expression to an expression, not a statement. (e.g. what if fun returns a result?) I considered this lowering for int fun

Re: Erroneous auto can only be used for template function parameters?

2015-06-22 Thread Yuxuan Shui via Digitalmars-d-learn
On Monday, 22 June 2015 at 13:49:21 UTC, Steven Schveighoffer wrote: On 6/20/15 10:26 PM, Yuxuan Shui wrote: On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote: On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote: auto ref R) is indeed a template function, so I don't

Re: auto ref is on the docket

2015-06-22 Thread via Digitalmars-d
On Monday, 22 June 2015 at 13:49:31 UTC, Jonathan M Davis wrote: On Monday, 22 June 2015 at 13:23:47 UTC, Marc Schütz wrote: On Monday, 22 June 2015 at 04:11:41 UTC, Andrei Alexandrescu wrote: Walter and I discussed what auto ref for templates should look like and reached the conclusion

Re: auto ref is on the docket

2015-06-22 Thread via Digitalmars-d
On Monday, 22 June 2015 at 15:39:38 UTC, Andrei Alexandrescu wrote: On 6/22/15 3:04 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Just lower it to: { auto tmp = 5; fun(tmp); } You need to lower an expression to an expression, not a statement. (e.g

Re: Erroneous auto can only be used for template function parameters?

2015-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/22/15 1:37 PM, Yuxuan Shui wrote: On Monday, 22 June 2015 at 13:49:21 UTC, Steven Schveighoffer wrote: On 6/20/15 10:26 PM, Yuxuan Shui wrote: On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote: On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote: auto ref R

Re: auto ref is on the docket

2015-06-22 Thread Daniel N via Digitalmars-d
On Monday, 22 June 2015 at 05:25:57 UTC, Walter Bright wrote: The idea is that fun(5) would be lowered to: auto tmp = 5; fun(tmp); But when talking to Andrei I didn't realize that it would be subtly different behavior than 'auto ref' for template functions, which makes me concerned

Re: auto ref is on the docket

2015-06-22 Thread Daniel N via Digitalmars-d
On Monday, 22 June 2015 at 20:50:23 UTC, Namespace wrote: That would be horrible. How would you distinguish between lvalues and rvalues? What if you want to store a pointer to an lvalue? If ref accept both you cannot do that. storing requires 'return ref'

Re: auto ref is on the docket

2015-06-22 Thread Namespace via Digitalmars-d
On Monday, 22 June 2015 at 20:42:58 UTC, Daniel N wrote: On Monday, 22 June 2015 at 05:25:57 UTC, Walter Bright wrote: The idea is that fun(5) would be lowered to: auto tmp = 5; fun(tmp); But when talking to Andrei I didn't realize that it would be subtly different behavior than 'auto

Re: auto ref is on the docket

2015-06-22 Thread Daniel N via Digitalmars-d
It's no worse than auto ref. It's only by convention that auto ref functions doesn't mutate, at least I follow that convention, but when looking at someone else's function, all bets are off.

Re: auto ref is on the docket

2015-06-22 Thread Timon Gehr via Digitalmars-d
the proposed `in ref T`/`const auto ref T` *shudder* equivalents if const-transitiveness would be violated. In my day-to-day C++ work, I almost never have to do that. Note almost.

Re: Erroneous auto can only be used for template function parameters?

2015-06-22 Thread Yuxuan Shui via Digitalmars-d-learn
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote: Try to compile this code snippet: import std.traits; template a(R) { auto a(S)(auto ref R i) { return cast(S)i*2; } } template ReturnTypeEx(alias A, B) { alias ReturnTypeEx = ReturnType!(A!B

Re: auto ref is on the docket

2015-06-22 Thread Timon Gehr via Digitalmars-d
On 06/22/2015 06:11 AM, Andrei Alexandrescu wrote: Walter and I discussed what auto ref for templates should look like and reached the conclusion that an approach based on lowering would be best. I added a proposed lowering to https://github.com/D-Programming-Language/dmd/pull/4717. Andrei

Re: auto ref is on the docket

2015-06-22 Thread Timon Gehr via Digitalmars-d
On 06/23/2015 12:40 AM, Andrei Alexandrescu wrote: On 6/22/15 3:06 PM, Timon Gehr wrote: On 06/22/2015 06:11 AM, Andrei Alexandrescu wrote: Walter and I discussed what auto ref for templates should look like and reached the conclusion that an approach based on lowering would be best. I added

Re: auto ref is on the docket

2015-06-22 Thread Dennis Ritchie via Digitalmars-d
On Monday, 22 June 2015 at 04:11:41 UTC, Andrei Alexandrescu wrote: Walter and I discussed what auto ref for templates should look like and reached the conclusion that an approach based on lowering would be best. I added a proposed lowering to https://github.com/D-Programming-Language/dmd/pull

Re: Erroneous auto can only be used for template function parameters?

2015-06-22 Thread Jesse Phillips via Digitalmars-d-learn
On Sunday, 21 June 2015 at 02:37:59 UTC, Yuxuan Shui wrote: On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote: On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote: auto ref R) is indeed a template function, so I don't understand. But R is not a parameter on the function

Re: auto ref is on the docket

2015-06-22 Thread kinke via Digitalmars-d
restriction imposed by D and only prevents you from using the proposed `in ref T`/`const auto ref T` *shudder* equivalents if const-transitiveness would be violated. In my day-to-day C++ work, I almost never have to do that. Note almost. Ah, I remember you from another rvalue discussion some years

[Issue 5941] Using inner struct which references nested function in a no-attribute or auto-return member function causes nested function cannot be accessed error

2015-06-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5941 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added Status|NEW |RESOLVED

Re: auto ref is on the docket

2015-06-22 Thread Andrei Alexandrescu via Digitalmars-d
On 6/22/15 4:09 PM, Timon Gehr wrote: There is no reason to prevent templates from using the mechanism that generates only one copy. The two mechanisms shouldn't share the same syntax, because then there is no way to tell them apart for template functions. I understand. For my money I'd be

Re: auto ref is on the docket

2015-06-22 Thread Timon Gehr via Digitalmars-d
it is. It's just an additional restriction imposed by D and only prevents you from using the proposed `in ref T`/`const auto ref T` *shudder* equivalents if const-transitiveness would be violated. In my day-to-day C++ work, I almost never have to do that. Note almost. ... Care to share

<    7   8   9   10   11   12   13   14   15   16   >