Thread overview
Assignments - preconditional
Feb 04, 2002
Brian Bober
Feb 04, 2002
Pavel Minayev
Feb 04, 2002
Sean L. Palmer
Feb 05, 2002
Walter
February 04, 2002
I was following the assignment thread and decided to start a new thread since it was getting cluttered.

I have an idea that I hope everyone will agree with.

Assignments should not be allowed inside conditionals.

Before a conditional, we could have a pre-conditional statment.

It's basically like a macro except you don't need a #define statement and it
only lasts
until the first conditional. It would also follow all the variable naming
rules except for having
a $ in front.

for instance:

typedef bit[8] byte;
byte c=0;
byte b=0;
byte a=100;
$a :  b=c*2;
while (a != $a)
{
    c+=1;
}

would be this in c++:

unsigned char c=0;
unsigned char b=1;
unsigned char a=100;
while (a != b=c*2)
{
    c+=1;
}




February 04, 2002
"Brian Bober" <netdemonz@yahoo.com> wrote in message news:a3ldkd$ndc$1@digitaldaemon.com...

> It's basically like a macro except you don't need a #define statement and
it
> only lasts
> until the first conditional. It would also follow all the variable naming
> rules except for having
> a $ in front.
>
> for instance:
>
> typedef bit[8] byte;
> byte c=0;
> byte b=0;
> byte a=100;
> $a :  b=c*2;
> while (a != $a)
> {
>     c+=1;
> }

Well...

    int d = (b = c * 2);
    while (a != d) ...

=)



February 04, 2002
Well, IMO Brian's is ugly and smells strongly of kludge.

Pavel, your replacement doesn't do the same thing.

I don't mind assignments in conditionals, but they should be explicitly converted to bool (bit) or the compiler should at least issue a warning.

Sean

"Pavel Minayev" <evilone@omen.ru> wrote in message news:a3lkel$shg$1@digitaldaemon.com...
> "Brian Bober" <netdemonz@yahoo.com> wrote in message news:a3ldkd$ndc$1@digitaldaemon.com...
>
> > It's basically like a macro except you don't need a #define statement
and
> it
> > only lasts
> > until the first conditional. It would also follow all the variable
naming
> > rules except for having
> > a $ in front.
> >
> > for instance:
> >
> > typedef bit[8] byte;
> > byte c=0;
> > byte b=0;
> > byte a=100;
> > $a :  b=c*2;
> > while (a != $a)
> > {
> >     c+=1;
> > }
>
> Well...
>
>     int d = (b = c * 2);
>     while (a != d) ...
>
> =)



February 05, 2002
"Brian Bober" <netdemonz@yahoo.com> wrote in message news:a3ldkd$ndc$1@digitaldaemon.com...
> I was following the assignment thread and decided to start a new thread since it was getting cluttered.
>
> I have an idea that I hope everyone will agree with.
>
> Assignments should not be allowed inside conditionals.

That's already the case in D.