Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Steven Schveighoffer
On Mon, 11 Feb 2013 14:56:29 -0500, Steven Schveighoffer wrote: On Mon, 11 Feb 2013 14:52:51 -0500, Steven Schveighoffer wrote: With that change, then you can compile my original suggestion, or my later suggestion. Actually, it seems that even args.join(" ") works, without changing t

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Jonathan M Davis
On Monday, February 11, 2013 14:56:29 Steven Schveighoffer wrote: > On Mon, 11 Feb 2013 14:52:51 -0500, Steven Schveighoffer > > wrote: > > With that change, then you can compile my original suggestion, or my > > later suggestion. > > Actually, it seems that even args.join(" ") works, without ch

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Steven Schveighoffer
On Mon, 11 Feb 2013 14:52:51 -0500, Steven Schveighoffer wrote: With that change, then you can compile my original suggestion, or my later suggestion. Actually, it seems that even args.join(" ") works, without changing to the tail-const type... That is technically correct, but I'm not

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Steven Schveighoffer
On Mon, 11 Feb 2013 13:59:41 -0500, Dicebot wrote: Ye, looks like this is the root of problem, I tweaked at a bit and have come to the same conclusion :( Sad, I really hoped I simply have overlooked some common idiom. This is a bug, joinImpl compiles with the given type, it's just join tha

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
Ye, looks like this is the root of problem, I tweaked at a bit and have come to the same conclusion :( Sad, I really hoped I simply have overlooked some common idiom.

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
I know all of this. When I speak about "original" array, I mean function parameter itself, not one passed to function. Actually, nevermind, Jonathan has kind of answered my question.

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Regan Heath
On Mon, 11 Feb 2013 17:13:21 -, Dicebot wrote: On Monday, 11 February 2013 at 16:54:04 UTC, Jonathan M Davis wrote: The const(T)[] cannot alter the original array at all, so I concur with Steven in that the complaints about not wanting to use tail-const make no sense. Maybe this articl

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Steven Schveighoffer
On Mon, 11 Feb 2013 12:01:53 -0500, Dicebot wrote: On Monday, 11 February 2013 at 16:35:22 UTC, Steven Schveighoffer wrote: in means "const scope". scope is a no-op, const makes the array const, including the pointer length. const(T)[] means, the ELEMENTS are const, but the pointer and len

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Jonathan M Davis
On Monday, February 11, 2013 18:01:53 Dicebot wrote: > On Monday, 11 February 2013 at 16:35:22 UTC, Steven Schveighoffer > > wrote: > > in means "const scope". scope is a no-op, const makes the > > array const, including the pointer length. > > > > const(T)[] means, the ELEMENTS are const, but th

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
On Monday, 11 February 2013 at 16:53:53 UTC, Jonathan M Davis wrote: On Monday, February 11, 2013 17:42:13 Dicebot wrote: On Monday, 11 February 2013 at 16:25:35 UTC, Dmitry Olshansky wrote: > I might be wrong but you can slice it e.g.: > > args[].join(" "); [], as well as [0.$] does return

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
On Monday, 11 February 2013 at 16:54:04 UTC, Jonathan M Davis wrote: The const(T)[] cannot alter the original array at all, so I concur with Steven in that the complaints about not wanting to use tail-const make no sense. Maybe this article will help clear things up: And I exactly want to pro

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
On Monday, 11 February 2013 at 16:35:22 UTC, Steven Schveighoffer wrote: in means "const scope". scope is a no-op, const makes the array const, including the pointer length. const(T)[] means, the ELEMENTS are const, but the pointer and length can be changed. This makes it a valid input range

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Jonathan M Davis
On Monday, February 11, 2013 11:35:22 Steven Schveighoffer wrote: > in means "const scope". scope is a no-op, const makes the array const, > including the pointer length. I would point out that that may change in the future. scope is supposed to stop references escaping in general but is only par

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Jonathan M Davis
On Monday, February 11, 2013 17:42:13 Dicebot wrote: > On Monday, 11 February 2013 at 16:25:35 UTC, Dmitry Olshansky > > wrote: > > I might be wrong but you can slice it e.g.: > > > > args[].join(" "); > > [], as well as [0.$] does return the very same qualified slice, > have tried it. For arra

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
On Monday, 11 February 2013 at 16:25:35 UTC, Dmitry Olshansky wrote: I might be wrong but you can slice it e.g.: args[].join(" "); [], as well as [0.$] does return the very same qualified slice, have tried it.

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Steven Schveighoffer
On Mon, 11 Feb 2013 10:26:40 -0500, Dicebot wrote: On Monday, 11 February 2013 at 15:06:26 UTC, Steven Schveighoffer wrote: On Mon, 11 Feb 2013 09:46:54 -0500, Dicebot wrote: This question is so stupid I am just struck with trying to chose the "good" solution. Consider this code: stri

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dmitry Olshansky
11-Feb-2013 18:46, Dicebot пишет: This question is so stupid I am just struck with trying to chose the "good" solution. Consider this code: string func(in string[] args) { return args.join(" "); // compile error, args is not an input range } I might be wrong but you can slice it e.g.: a

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread bearophile
Dicebot: string func(in string[] args) { return args.join(" "); // compile error, args is not an input range } join() should to able to join a const array of strings. Bye, bearophile

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
On Monday, 11 February 2013 at 14:53:17 UTC, Namespace wrote: On Monday, 11 February 2013 at 14:46:55 UTC, Dicebot wrote: This question is so stupid I am just struck with trying to chose the "good" solution. Consider this code: string func(in string[] args) { return args.join(" "); // comp

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
On Monday, 11 February 2013 at 15:06:26 UTC, Steven Schveighoffer wrote: On Mon, 11 Feb 2013 09:46:54 -0500, Dicebot wrote: This question is so stupid I am just struck with trying to chose the "good" solution. Consider this code: string func(in string[] args) { return args.join(" "); /

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Steven Schveighoffer
On Mon, 11 Feb 2013 09:46:54 -0500, Dicebot wrote: This question is so stupid I am just struck with trying to chose the "good" solution. Consider this code: string func(in string[] args) { return args.join(" "); // compile error, args is not an input range } It is somewhat expected as

Re: Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Namespace
On Monday, 11 February 2013 at 14:46:55 UTC, Dicebot wrote: This question is so stupid I am just struck with trying to chose the "good" solution. Consider this code: string func(in string[] args) { return args.join(" "); // compile error, args is not an input range } It is somewhat expe

Idiomatic way to process const/immutable arrays as ranges

2013-02-11 Thread Dicebot
This question is so stupid I am just struck with trying to chose the "good" solution. Consider this code: string func(in string[] args) { return args.join(" "); // compile error, args is not an input range } It is somewhat expected as you can hardly popFront on a const range. But then q