## digitalmars.D.learn - "is" expression and type tuples

• Jack Applegame (2/6) Mar 03 2015 Is it by design, or just not implemented?
• bearophile (7/14) Mar 03 2015 It's by design, perhaps because Walter didn't think of this case,
• Jack Applegame (2/13) Mar 03 2015
• bearophile (4/15) Mar 03 2015 That's 1 + n-1 :-)
• Jack Applegame (2/3) Mar 03 2015 Could you please explain what does '1 + n-1' mean?
• bearophile (21/30) Mar 04 2015 The recursion scheme you are using is working on a single item (a
"Jack Applegame" <japplegame gmail.com> writes:
Seems like "is" expression doesn't support type tuples:

pragma(msg, is(short : int));                 // true

enum Test(ARGS...) = is(ARGS[0..2] : ARGS[2..4]);
pragma(msg, is(Test!(int, int, int, int)));   // false
pragma(msg, Test!(int, short, int, int));     // false
Is it by design, or just not implemented?
Mar 03 2015
"bearophile" <bearophileHUGS lycos.com> writes:
Jack Applegame:

Seems like "is" expression doesn't support type tuples:

pragma(msg, is(short : int));                 // true

enum Test(ARGS...) = is(ARGS[0..2] : ARGS[2..4]);
pragma(msg, is(Test!(int, int, int, int)));   // false
pragma(msg, Test!(int, short, int, int));     // false
Is it by design, or just not implemented?
It's by design, perhaps because Walter didn't think of this case, or probably for compiler simplicity. But it should be not too much hard to implement it your code. Just use two is(), or use recursion (with splitting in two, and not 1 + n-1). Bye, bearophile
Mar 03 2015
"Jack Applegame" <japplegame gmail.com> writes:
On Tuesday, 3 March 2015 at 16:42:22 UTC, bearophile wrote:
But it should be not too much hard to implement it your code.
Just use two is(), or use recursion (with splitting in two, and
not 1 + n-1).

Bye,
bearophile
template Is(ARGS...) if(ARGS.length % 2 == 0) {
enum N = ARGS.length/2;
static if(N == 1) enum Is = is(ARGS[0] : ARGS[1]);
else enum Is = is(ARGS[0] : ARGS[N]) && Is!(ARGS[1..N],
ARGS[N+1..\$]);
}
Mar 03 2015
"bearophile" <bearophileHUGS lycos.com> writes:
Jack Applegame:

or use recursion (with splitting in two, and not 1 + n-1).

Bye,
bearophile
template Is(ARGS...) if(ARGS.length % 2 == 0) {
enum N = ARGS.length/2;
static if(N == 1) enum Is = is(ARGS[0] : ARGS[1]);
else enum Is = is(ARGS[0] : ARGS[N]) && Is!(ARGS[1..N],
ARGS[N+1..\$]);
}
That's 1 + n-1 :-) Bye, bearophile
Mar 03 2015
"Jack Applegame" <japplegame gmail.com> writes:
On Tuesday, 3 March 2015 at 17:49:24 UTC, bearophile wrote:
That's 1 + n-1 :-)
Could you please explain what does '1 + n-1' mean?
Mar 03 2015
"bearophile" <bearophileHUGS lycos.com> writes:
Jack Applegame:

On Tuesday, 3 March 2015 at 17:49:24 UTC, bearophile wrote:
That's 1 + n-1 :-)
Could you please explain what does '1 + n-1' mean?