www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: (git HEAD) std.datetime spewing deprecation messages

reply Jonathan M Davis via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Thu, 05 Jun 2014 18:18:33 -0400
Steven Schveighoffer via Digitalmars-d <digitalmars-d puremagic.com>
wrote:

 On Thu, 05 Jun 2014 18:06:01 -0400, monarch_dodra
 <monarchdodra gmail.com> wrote:

 On Thursday, 5 June 2014 at 08:49:18 UTC, Jonathan M Davis via
 Digitalmars-d
     long days;
     int seconds;
     short msecs;
     d.split!("days", "seconds", "msecs")(&days, &seconds, &msecs);

Please don't use pass-by-pointer in D APIs. It makes it a real *nightmare* to ever use the code in a safe context.

This is similar to getopt and readf. I think it's a good way to show that a reference is being passed.

And like with them, it's impossible to use ref for this, because you can't use ref with variadic template arguments. So, there isn't even any debate as to whether ref or pointers would be nicer. Since it's _impossible_ to use ref for this, there's no choice. Anyone who doesn't want to use pointers can use the overload that returns a struct rather than taking function arguments. If there were a way to use ref with variadic arguments, then we could discuss which is better, but since pointers are the only option, there's no point in discussing it. - Jonathan M Davis
Jun 05 2014
next sibling parent "Dicebot" <public dicebot.lv> writes:
On Friday, 6 June 2014 at 00:34:19 UTC, Jonathan M Davis via 
Digitalmars-d wrote:
 And like with them, it's impossible to use ref for this, 
 because you can't use
 ref with variadic template arguments.

Wait what? void foo(T...)(ref T args) { args[0] = 42; } void main() { int x; foo(x); assert(x == 42); }
Jun 06 2014
prev sibling next sibling parent Jonathan M Davis via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Fri, 06 Jun 2014 08:14:13 +0000
Dicebot via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 On Friday, 6 June 2014 at 00:34:19 UTC, Jonathan M Davis via
 Digitalmars-d wrote:
 And like with them, it's impossible to use ref for this,
 because you can't use
 ref with variadic template arguments.

Wait what? void foo(T...)(ref T args) { args[0] = 42; } void main() { int x; foo(x); assert(x == 42); }

Well, that's new then. You didn't used to be able to do that. I clearly missed that change. Thanks for the correction. I'd still use pointers in this case though, since it's clearer and consistent with existing code like getopt. - Jonathan M Davis
Jun 06 2014
prev sibling next sibling parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Friday, 6 June 2014 at 09:35:56 UTC, Jonathan M Davis via 
Digitalmars-d wrote:
 On Fri, 06 Jun 2014 08:14:13 +0000
 Dicebot via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 On Friday, 6 June 2014 at 00:34:19 UTC, Jonathan M Davis via
 Digitalmars-d wrote:
 And like with them, it's impossible to use ref for this,
 because you can't use
 ref with variadic template arguments.

Wait what? void foo(T...)(ref T args) { args[0] = 42; } void main() { int x; foo(x); assert(x == 42); }

Well, that's new then. You didn't used to be able to do that. I clearly missed that change. Thanks for the correction. I'd still use pointers in this case though, since it's clearer and consistent with existing code like getopt. - Jonathan M Davis

And strongly system.
Jun 06 2014
prev sibling parent "Dicebot" <public dicebot.lv> writes:
On Friday, 6 June 2014 at 10:35:58 UTC, monarch_dodra wrote:
 On Friday, 6 June 2014 at 09:35:56 UTC, Jonathan M Davis via 
 Digitalmars-d wrote:
 On Fri, 06 Jun 2014 08:14:13 +0000
 Dicebot via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 On Friday, 6 June 2014 at 00:34:19 UTC, Jonathan M Davis via
 Digitalmars-d wrote:
 And like with them, it's impossible to use ref for this,
 because you can't use
 ref with variadic template arguments.

Wait what? void foo(T...)(ref T args) { args[0] = 42; } void main() { int x; foo(x); assert(x == 42); }

Well, that's new then. You didn't used to be able to do that. I clearly missed that change. Thanks for the correction. I'd still use pointers in this case though, since it's clearer and consistent with existing code like getopt. - Jonathan M Davis

And strongly system.

This alone is absolutely blocking objection against pointer-based decomposition in my opinion. Liked simple design with returning struct most.
Jun 06 2014