On Tuesday, 5 May 2015 at 18:37:52 UTC, Justin Whear wrote:
How's this? http://dpaste.dzfl.pl/d6643ec8ccd3
Yes, something like that. In my opinion, it's really easier than
static if in some cases.
On Tuesday, 5 May 2015 at 18:12:42 UTC, Ali Çehreli wrote:
Personally, I haven't felt the need for this becuase usually
there is something different only for one or two specific types.
I don't see that the syntax becomes shorter to warrant a
language addition either. (However, the risk of writ
How's this? http://dpaste.dzfl.pl/d6643ec8ccd3
se static if (is(T == real)) {
> // ...
> } else static if (is(T == char)) {
> // ...
> } else static if (is(T == string)) {
> // ...
> } else static if (is(T == int[])) {
> // ...
> } else {
> // ...
> }
>
> Why not put in Phobos shorter des
On Monday, 4 May 2015 at 22:48:37 UTC, Dennis Ritchie wrote:
Why not put in Phobos shorter design type switch:
*More precisely, not in Phobos and DMD.
(is(T == char)) {
// ...
} else static if (is(T == string)) {
// ...
} else static if (is(T == int[])) {
// ...
} else {
// ...
}
Why not put in Phobos shorter design type switch:
// -
type switch (T) {
case short, int, long:
// do anything
case
r a string, an enum for a symbol or keyword, etc. So the type of the value
> field is "object", and you use the token type to tell you how to cast the
> value field when you use it.
>
> The Lava solution to this problem is to allow an explicit type switch:
>
> switch (valu
how to cast the value field
when you use it.
The Lava solution to this problem is to allow an explicit type switch:
switch (value.type) {
case int: // value is an int
value += 3;
break;
case string: // value is a string
string sub = substring(value, 1, 5);
break;
ca