-3
My challenge is language-specific, but needs a lot of creativity: write a valid C program with only one pair of braces {}
and none of the keywords if
, for
, while
(all checked after preprocessing, and after substituting trigraphs). I'm looking for preprocessor abuse (but other methods are also welcome) to define a new pseudo-language which supports at least if
/else
, then use that language to do something cool.
That's pretty easy, and I'll just score this by upvotes since any scoring would be rather arbitrary, but here are some things which would be impressive:
- function calls (also arguments, return values);
else if
;switch
/case
(alsodefault
, fall-through);for
orwhile
(super-impressive. Alsobreak
,continue
);- having only one semicolon
;
(This one makes the challenge a bit different); - an interesting program;
- full portability (portable in practice is good, portable in theory is even better).
This isn't about obfuscation. The preprocessor statements will probably be a bit hairy, but the actual code should be very easy to follow.
goto
is allowed, but I believe it won't help much.
3To avoid braces, use goto statements. – Joe Z. – 2013-08-22T03:35:01.643
2Just a pedantic point that is really bugging me. There are no "implied braces" in a one line
if
/else
construct. That thing works on single statements by design. The braces are a trick for making it work on multiple statements not the other way 'round. In any case, I'm with joe, c supportsgoto
which means it supports unstructured programming. Welcome back to the big ball o'mud. – dmckee --- ex-moderator kitten – 2013-08-22T03:55:02.9501Like dmckee, I don't get the implied braces idea. Are you forbidding
if
? Also, if braces are not allowed after preprocessing, what good will preprocessor abuse do? – ugoren – 2013-08-22T04:38:37.953Uh... [! Nobody mention trigrams. ] – luser droog – 2013-08-22T04:40:04.690
Trigrams is a good point. Oops. (Unless those are handled by the pre processor, I'm not sure). @dmckee I did consider
goto
, but it won't help you unless you can getif
working. And as for "implied braces", I see your point, so I suppose really I'm banning the nativeif
,else
,for
, etc. (again after preprocessing). The intent of the challenge is to defining a pseudo-language which uses something other than braces to mark blocks. It's possible in at least one way, and I found it an interesting challenge; thought others might too. – Dave – 2013-08-22T10:12:49.517@luserdroog pre processor abuse is really just to make the thing readable. I see your point about braces, so: yes. I am forbidding
if
,for
, etc. (after preprocessing & trigraph substitution) – Dave – 2013-08-22T10:15:02.730I feel I should restrict assembly too, but frankly, if somebody can make a portable, readable answer which uses assembly, I'm all for it. – Dave – 2013-08-22T10:30:39.303