Journal tomhudson's Journal: test file for c_for_dummies.h 4
#include "c_for_dummies.h"
/* compile using theo following command:
* gcc -E "filename.c" | indent - br
* to see the generated source code.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
MAIN
int i, total;
FOR i=total=0; i<10; i++ DO
total += i;
END_FOR
printf("total = %d\n", total);
FOR i=total=0; i<10; i++ DO
printf("i=%d, total=%d\n", i, total);
IF i== 5 THEN LOOP
total += i;
IF i==8 THEN SKIP_THE_REST
END_FOR
total += i;
printf("now i=%d, total=%d\n", i, total);
MATCH i
IF_IS_A 5 THEN_DO
printf("it's a five\n")
OR_IS_A 7 THEN_DO
printf("it's a seven\n")
OR_IS_A 9 THEN_DO
printf("it's a nine\n")
OR_IS_A 1 OR_A 3 THEN_DO
printf("at least it's odd\n")
OTHERWISE
printf("it's really %d\n", i)
END_MATCH
i=0, total=0;
REPEAT
i++, total += i;
printf("i=%d, total=%d\n", i, total)
AS_LONG_AS i < 10
END_REPEAT
WHILE i > 0 DO
total -= i, i--;
printf("i=%d, total=%d\n", i, total)
END_WHILE
i--;
IF i==0 THEN
printf("i equals zero\n")
ELSE_IF i > 0 THEN
printf("i is greater than zero\n")
ELSE
printf("i is smaller than zero\n")
END_IF
END_MAIN
/* compile using theo following command:
* gcc -E "filename.c" | indent - br
* to see the generated source code.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
MAIN
int i, total;
FOR i=total=0; i<10; i++ DO
total += i;
END_FOR
printf("total = %d\n", total);
FOR i=total=0; i<10; i++ DO
printf("i=%d, total=%d\n", i, total);
IF i== 5 THEN LOOP
total += i;
IF i==8 THEN SKIP_THE_REST
END_FOR
total += i;
printf("now i=%d, total=%d\n", i, total);
MATCH i
IF_IS_A 5 THEN_DO
printf("it's a five\n")
OR_IS_A 7 THEN_DO
printf("it's a seven\n")
OR_IS_A 9 THEN_DO
printf("it's a nine\n")
OR_IS_A 1 OR_A 3 THEN_DO
printf("at least it's odd\n")
OTHERWISE
printf("it's really %d\n", i)
END_MATCH
i=0, total=0;
REPEAT
i++, total += i;
printf("i=%d, total=%d\n", i, total)
AS_LONG_AS i < 10
END_REPEAT
WHILE i > 0 DO
total -= i, i--;
printf("i=%d, total=%d\n", i, total)
END_WHILE
i--;
IF i==0 THEN
printf("i equals zero\n")
ELSE_IF i > 0 THEN
printf("i is greater than zero\n")
ELSE
printf("i is smaller than zero\n")
END_IF
END_MAIN
ADA code? (Score:1)
That looks kind of sort of like ADA [adaic.org] or the other Pascal'ish languages.
I use (current tense) kind of similar concepts in plain ADA:
Re: (Score:2)
AAAAAAAAH (Score:2, Funny)
Are you trying to kill me or something? I like Modula-2 as much as the next guy. Hell, it was one of my first programming languages. But please don't make C look like that. It's blasphemy.
It reminds me of the ultimate computer language troll. I'd piss off as many Java programmers as I could by creating a Java binding for the C standard library. Throw away those streams and object crap. Just call fopen from Java!
Re: (Score:2)
Ah, but it's FUN blasphemy. It's my answer to those who dislike terseness in c code, the eschewing of braces where not needed, use of the comma operator where it helps (and not just in for loop initialization), and in general like to clutter the screen with as much white space as possible with such tactics as listing parameters one per line, braces around everything, and always on a line of their own, etc.
If they're so worried that not using braces to blockify single-line statements in an if will lead to