Jump to page: 1 2
Thread overview
x,y,z = 0;
May 22, 2002
Juarez Rudsatz
May 22, 2002
Russ Lewis
May 22, 2002
Juarez Rudsatz
May 23, 2002
anderson
May 23, 2002
Matthew Wilson
May 23, 2002
anderson
May 24, 2002
anderson
May 24, 2002
anderson
May 24, 2002
anderson
May 25, 2002
anderson
May 23, 2002
Russ Lewis
May 24, 2002
anderson
May 24, 2002
Sandor Hojtsy
May 23, 2002
Sean L. Palmer
May 23, 2002
anderson
May 22, 2002
Just a new `Sintatic Sugar' :

int x, y, z;

x, y, z = 0;  // initialize all variables at same time

// instead of

x = 0; y = 0; z = 0;

x, y, z = veryLowFunctionCalled();

// instead of

int i;

i = veryLowFunctionCalled();

x = i; y = i; z = i;

// and folowing

int[] a, b, c;

a[], b[3..5], b[6..7], c[x..y] = 0;

// and more madness still

x, y, z = 0, 3 , 9 ? 1 : 2;

pros
o	less typing
o	optimization
o	less code height

cons
o	unusual in C*
o	ugly
o	code not so clear

Question, Sugestion, Negatives ?
May 22, 2002
Why not
    x = y = z = 0;

???

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


May 22, 2002
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;
May 23, 2002

"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 23, 2002
It's a matter of precedence of operators.

In C/C++, operator comma is lower precedence than anything.

They're asking for comma to be moved up two notches past the assignment operators.

I thought Walter was against altering precedence.  I don't care one way or the other... the new precedence would work too I think and seems to make an interesting language.  It could feel natural that way.  Would take some getting used to which is what prompts Walter's reasoning.

A similar change is the one that allows

void Swap(inout Foo a, inout Foo b)
{
   Foo temp = a = b = temp;
}

Which language lets you do that?  Lisp or something maybe.  I forget.

Anyway I think Walter wants D to stay closer to its C roots.  I think sometimes change is a good thing.  D is definitely not going to be 100% C compatible anyway so code will need ported anyway, it's just one little thing and if it makes the language easier to work in, I'd say go for it; the people porting the code are probably doing so not because D is the coolest thing to port their C++ code to, but because they like working in D and need to interface to some old code to be productive.   They'll take the time to interface to it (if they're smart, and so long as it's possible) or port it (if they're ambitious, or willing to do the nearly impossible, and have access to the source).

Sean

"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;


May 23, 2002
This is all hideous.

Verbose does not mean obfuscated, often the reverse.


"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 23, 2002
I doesn't necessarily have to be comma if precedence is so important. Can you think of another neat symbol that would do the task?

"Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:aci76p$2on7$1@digitaldaemon.com...
> It's a matter of precedence of operators.
>
> In C/C++, operator comma is lower precedence than anything.
>
> They're asking for comma to be moved up two notches past the assignment operators.
>
> I thought Walter was against altering precedence.  I don't care one way or the other... the new precedence would work too I think and seems to make
an
> interesting language.  It could feel natural that way.  Would take some getting used to which is what prompts Walter's reasoning.
>
> A similar change is the one that allows
>
> void Swap(inout Foo a, inout Foo b)
> {
>    Foo temp = a = b = temp;
> }
>
> Which language lets you do that?  Lisp or something maybe.  I forget.
>
> Anyway I think Walter wants D to stay closer to its C roots.  I think sometimes change is a good thing.  D is definitely not going to be 100% C compatible anyway so code will need ported anyway, it's just one little thing and if it makes the language easier to work in, I'd say go for it;
the
> people porting the code are probably doing so not because D is the coolest thing to port their C++ code to, but because they like working in D and
need
> to interface to some old code to be productive.   They'll take the time to interface to it (if they're smart, and so long as it's possible) or port
it
> (if they're ambitious, or willing to do the nearly impossible, and have
> access to the source).
>
> Sean
>
> "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;
>
>


May 23, 2002
"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 23, 2002
anderson wrote:

> Why not make...
>     a[] = b[3..5] = b[6..447] = c[x..y] = 0;
> ...legal?

This syntax already exists...it is array copy syntax.  However, it would fail because the size of the ranges vary.

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


May 24, 2002
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)


"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3CED2563.AFAF2DB1@deming-os.org...
> anderson wrote:
>
> > Why not make...
> >     a[] = b[3..5] = b[6..447] = c[x..y] = 0;
> > ...legal?
>
> This syntax already exists...it is array copy syntax.  However, it would fail because the size of the ranges vary.
>
> --
> The Villagers are Online! villagersonline.com
>
> .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
> .[ (a version.of(English).(precise.more)) is(possible) ]
> ?[ you want.to(help(develop(it))) ]
>
>


« First   ‹ Prev
1 2