alternatives to making blocks like { } or other ??

Dan Bishop danb_83 at yahoo.com
Thu May 20 03:19:12 EDT 2004


Grant Edwards <grante at visi.com> wrote in message news:<slrncalqqf.8f2.grante at grante.rivatek.com>...
> On 2004-05-18, CYBER <usenet at zly_adres.com> wrote:
> >> Of course there is another way!
> >> 
> >> Just use # in front of your favourite block separator.
...
> You realize that was a joke, right?
> 
> Please, please don't write code like that.  You'll be shunned
> just like the BASIC programmers who switched to C and pulled
> crap like
> 
> #define IF if (
> #define THEN ) {
> #define ELSE } else {
> #define ENDIF }

Also,

  #define ELSEIF } else if {

because using "ELSE IF" gives you unbalanced braces.
 
> #define WHILE while (
> #define DO ) {
> #define DONE }

I don't remember BASIC ever using the syntax "WHILE cond DO ... DONE";
you've probably got it mixed up with another language.

"WHILE cond ... WEND" would be more accurate, but then it's harder to
deal with the ")" on the first line.

Also, you might want to support the QBasic DO...LOOP syntax, which had
four forms:

' 1. Pretest loop (while), positive condition
DO WHILE cond : statements : LOOP
' 2. Pretest loop (while), negative condition
DO UNTIL cond : statements : LOOP
' 3. Posttest loop (do...while), positive condition
DO : statements : LOOP WHILE cond
' 4. Posttest loop (do...while), negative condition
DO : statements : LOOP UNTIL cond

I doubt it's even possible to #define DO, LOOP, WHILE, and UNTIL to
handle all of them.



More information about the Python-list mailing list