Forgot your password?
typodupeerror
Programming

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

This discussion has been archived. No new comments can be posted.

test file for c_for_dummies.h

Comments Filter:
  • 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:

    procedure Do_Main is
    Some_Local_Var : Integer := 0;
    begin
    Add_Stuff: -- Named loop
    For Each_Item in 1 .. 9 loop --each item gets elaborated/created based on the "1 .. 5" for what type it is, or it may be declared
    Some_Local_Var:= Some_Local_Var+ Each_Item;

  • 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!

    • 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

If you think nobody cares if you're alive, try missing a couple of car payments. -- Earl Wilson

Working...