May 24, 2002 Re: x,y,z = 0; | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | I just thought of something else that may work even better, but it has a hitch. if ( a == &&{b,c,d,e}) So, b,c,d,e get up into an array and then tested But & is used for reference operator.... Parhaps a space before the array like if ( a == && {b,c,d,e}) or if ( a == (&&){b,c,d,e}) or if ( a == and{b,c,d,e}) if ( a == or{b,c,d,e}) if ( a == zor{b,c,d,e}) and then you could int b[1000] = {...} if (a == and b) if (a == and b[1..20]) Syntax is not quite right, but I think you get the idea. "anderson" <anderson@firestar.com.au> wrote in message news:acids4$2ufi$1@digitaldaemon.com... > > "Matthew Wilson" <mwilson@nextgengaming.com> wrote in message news:aci7j9$2p84$1@digitaldaemon.com... > > This is all hideous. > > > > Verbose does not mean obfuscated, often the reverse. > > I know, I was mainly considering maintanance reasons. > > ie > > if ( a == &&(b, c, d, e)); > > instead of, > > if ((a == b && a == c && a == d && a == e)); > > If you had to change a, you'd have to either use find-replace or change it 4 > times, which leaves room for more error. Also a complier may be able to take > advantage of the former (but I'm sure most compilers could probably reconise > and optimise the later (loading "a" once) ). > > Also you could do something that would be huge such as > > if ( &&(x,y,z) != &&(a,b,c)); > > instead of, > > if ( x != a && x != b && x != c && > y != a && y != b && y != c && > z != a && z != b && z != c) > > which would would optimise to, > if (x != y && y != z && > a != b && b != c && > c != x) > > //Of coarse somthing like, > if ( &&(x,y,z) == &&(a,b,c)); > > would optimise to, > if (x == y && y == z && > a == b && b == c && > c == x) > > Which I suppose isn't a huge difference in code, but it would save on manual > optimisation. I wonder if the compiler does that type of optimisation? > > > PS - As I said before, parhaps the syntax could be change. ie > > if (a == and(b,c,d,e)); > if (a == or(b,c,d,e)); > > because personaly I like "and" and "or" better then "&&" and "||", but then > that would lead to function simularities. > > > > > > > "anderson" <anderson@firestar.com.au> wrote in message news:aci6ji$2o8h$1@digitaldaemon.com... > > > > > > > > > "Juarez Rudsatz" <juarez@correio.com> wrote in message news:3CEC0DB6.FD23A790@correio.com... > > > > Russ Lewis wrote: > > > > > > > > > > Why not > > > > > x = y = z = 0; > > > > > > > > > > ??? > > > > > > > > Because... > > > > > > > > int[] a, b, c; > > > > > > > > a[], b[3..5], b[6..447], c[x..y] = 0; > > > > > > Why not make... > > > a[] = b[3..5] = b[6..447] = c[x..y] = 0; > > > ...legal? > > > > > > Although Parhaps somthing simular to this could be used in comparisons. > > > > > > if (a == b || a == c || a == d); > > > > > > to something like, > > > > > > if ( a == ||(b, c, d) ); > > > > > > if (a == b && a == c && a == d); > > > > > > to something like, > > > > > > if ( a == &&(b, c, d) ); > > > > > > So you'd get things like, > > > > > > if ( a == &&(b, c, d) || e != ||(b, c, d)); > > > > > > instead of, > > > > > > if ((a == b && a == c && a == d) || (e != b || e != c || e != d)); > > > > > > Or parhaps someone could improve that that syntax. > > > > > > PS - what does the <<< do. > > > > > > Further note, I'd be nice if rotate (ie ><) and arithmetic shifts (????) > > > were also included. > > > > > > > > > > > > |
May 24, 2002 Re: x,y,z = 0; | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | Mistake, "anderson" <anderson@firestar.com.au> wrote in message news:ack4a4$1gkp$1@digitaldaemon.com... > I just thought of something else that may work even better, but it has a hitch. > > if ( a == &&{b,c,d,e}) > > So, b,c,d,e get up into an array and then tested > > But & is used for reference operator.... > > Parhaps a space before the array like > > if ( a == && {b,c,d,e}) > > or > > if ( a == (&&){b,c,d,e}) > > or > > if ( a == and{b,c,d,e}) > if ( a == or{b,c,d,e}) > if ( a == zor{b,c,d,e}) if ( a == xor{b,c,d,e}) > and then you could > > int b[1000] = {...} > > if (a == and b) > if (a == and b[1..20]) > > Syntax is not quite right, but I think you get the idea. |
May 24, 2002 Re: x,y,z = 0; | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | On thing I didn't think of with the current syntax is, int a = ...; if({a} == {d,e,f,g}) which would be like if(a == && {d,e,f,g}) but that wouldn't do xor or "or". "anderson" <anderson@firestar.com.au> wrote in message news:ack4a4$1gkp$1@digitaldaemon.com... > I just thought of something else that may work even better, but it has a hitch. > > if ( a == &&{b,c,d,e}) > > So, b,c,d,e get up into an array and then tested > > But & is used for reference operator.... > > Parhaps a space before the array like > > if ( a == && {b,c,d,e}) > > or > > if ( a == (&&){b,c,d,e}) > > or > > if ( a == and{b,c,d,e}) > if ( a == or{b,c,d,e}) > if ( a == xor{b,c,d,e}) > > and then you could > > int b[1000] = {...} > > if (a == and b) > if (a == and b[1..20]) > > Syntax is not quite right, but I think you get the idea. |
May 24, 2002 Re: x,y,z = 0; | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | "anderson" <anderson@firestar.com.au> wrote in message news:ack3sh$1g1m$1@digitaldaemon.com... > I'd be good if the comilper was able to pick this up as a special case (whenever consts are involved). It could also be used in comparisons. ie > > if (b[3..5] == 0) > > instead of > > if (b[3] == 0 && b[4] == 0 && b[5] == 0) Wow, that is quite intuitive. BTW, is it possible to create an unnamed dynamic array by composing it from elements? Such as: a[] = 3 ~ 4 ~ 5; fn(12 ~ 1); There are some problems here: a ~ b should concatenate the arrays not insert them as elements to a bigger one. What will be the base type of the array? So the ~ operator is not quite good in this context. Some other syntactic sugar? Yours, Sandor Hojtsy |
May 25, 2002 Re: x,y,z = 0; | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | "anderson" <anderson@firestar.com.au> wrote in message news:ack5m4$1i3s$1@digitaldaemon.com... > > On thing I didn't think of with the current syntax is, > > int a = ...; > > if({a} == {d,e,f,g}) What was I thinking. It should have been if({a,a,a,a} == {d,e,f,g}) Which isn't much better at all but it gave me a further idea. Parhaps if (a == {d,e,f,g}) instead of, if (a == d && a == e && a == f && a == g) Which makes && default getting rid of the referencial problem with &&. if (a == || {d,e,f,g}) instead of, if (a == d || a == e || a == f || a == g) if (a == ^^ {d,e,f,g}) instead of, if (a == d ^^ a == e ^^ a == f ^^ a == g) if (a == | {d,e,f,g}) instead of, if (a == d | a == e | a == f | a == g) and so on > > which would be like > > if(a == && {d,e,f,g}) > > but that wouldn't do xor or "or". > > "anderson" <anderson@firestar.com.au> wrote in message news:ack4a4$1gkp$1@digitaldaemon.com... > > I just thought of something else that may work even better, but it has a hitch. > > > > if ( a == &&{b,c,d,e}) > > > > So, b,c,d,e get up into an array and then tested > > > > But & is used for reference operator.... > > > > Parhaps a space before the array like > > > > if ( a == && {b,c,d,e}) > > > > or > > > > if ( a == (&&){b,c,d,e}) > > > > or > > > > if ( a == and{b,c,d,e}) > > if ( a == or{b,c,d,e}) > > if ( a == xor{b,c,d,e}) > > > > and then you could > > > > int b[1000] = {...} > > > > if (a == and b) > > if (a == and b[1..20]) > > > > Syntax is not quite right, but I think you get the idea. > > > |
Copyright © 1999-2021 by the D Language Foundation