Syntax errors ahoy!

Spinaroonie

LOOK WHAT I FOUND!
Joined
Jul 29, 2000
Posts
17,721
#include <iostreams.h>

PostLikeSpin(x)
Post
If Post = incomprehendable
THEN
{
GOTO END
}
If Post = Comprenedable
Then
{
EDIT ()
}
END

Waaaaaaaaaaaaaaaahahahahahahahahahhaahahahhaahahhahhahahhahhahhahahahahahahahahahahahahahahahahahahahahahhahahahahahahaa
 
Ahoy!

I heard someone say ahoy and was hoping we'd have a little plundering and plank walking... harrrrr....
 
Spinaroonie said:
#include <iostreams.h>

PostLikeSpin(x)
Post
If Post = incomprehendable
THEN
{
GOTO END
}
If Post = Comprenedable
Then
{
EDIT ()
}
END

You have to watch those typos while programming.
 
Spinaroonie said:
#include <iostreams.h>

PostLikeSpin(x)
Post
If Post = incomprehendable
THEN
{
GOTO END
}
If Post = Comprenedable
Then
{
EDIT ()
}
END
That is not legal C or C++:

shorthand form:

void postLikeSpin(string postText)
{
( ! incomprehensablePost( postText ) ) ? postToLit( postText ) : edit(postText);
}

long form:

void postLikeSpin(string postText)
{
if ( ! incomprehensablePost( postText ) )
{
postToLit( postText )
}
else
{
edit(postText);
}
}

Also, you have a number of other syntax errors:

1) You are doing an assignment with a single equals operator ( A = 2+3 ) is an assignment, (A == B), ( A != B) are boolean tests.

2) There is no "THEN" in C or C++

3) There is no implicit END label in C++

4) Never use GOTO in any language - never, never, never.
 
Re: Re: Syntax errors ahoy!

The Heretic said:

4) Never use GOTO in any language - never, never, never.

Best part of the last C++ class I took a long time ago... Watching the Prof hit the roof when a guy used a goto.
 
Re: Re: Re: Syntax errors ahoy!

Spinaroonie said:
Best part of the last C++ class I took a long time ago... Watching the Prof hit the roof when a guy used a goto.
Good for him!

There is almost no situation you can get yourself into with a well structured language like C, C++, Java or Pascal, where you need to use "goto". Sometimes in a big finite state machine, or something like that, a "goto" might get you a performance gain, but it is a bad, bad, bad construct to use - and should be avoided at all costs. It only exists because once in a million lines of code you need to bite your tongue and use it.

I used to work with someone who, while otherwise a pretty good programmer, used them all the time. Eventually we broke him of that habit. In the last ten years I have used the goto construct twice, and that was early on in my career.
 
I remember about age 17 there was some kind of programming competition at school. The computers they had were Acorn Archimedes with a shitty version of BASIC that I had never used before (line numbers mandatory). I wanted to write while loops in a program that converted decimal to roman numeral form (or vice versa), but there was no online help or documentation - was it WHILE...WEND, WHILE...ENDWHILE, DO WHILE...END? Eventually I gave up and used if and goto, purely to emulate while loops.

I got the highest mark in the school, the only thing that stopped me getting full marks was that cocksucking son of a bitch arsehole BBC BASIC.
 
claude_moveml said:
I got the highest mark in the school, the only thing that stopped me getting full marks was that cocksucking son of a bitch arsehole BBC BASIC.
BASIC, in whatever form, pretty much sucks because is lacks structure and therefore encourages use of such hacks as "goto". I avoid using any form of BASIC at all costs - I am a software engineer, not a masochist.
 
BASIC was the first language I learnt back on the Amstrad PCW 8256. Actually I might have learnt LOGO first. The language that I loved most was E on my Amiga, really fast compilation with loads of features (unification of lists and lisp cells, typeless object-orientedness, inline assembler, great GUI library).

I should have written this program for the Roman numeral problem ;)

http://www.es.ioccc.org/years.html#1987_wall

#define iv 4
#define v ;(void
#define XI(xi)int xi[iv*'V'];
#define L(c,l,i)c(){d(l);m(i);}
#include <stdio.h>
int*cc,c,i,ix='\t',exit(),X='\n'*'\d';XI(VI)XI(xi)extern(*vi[])(),(*
signal())();char*V,cm,D['x'],M='\n',I,*gets();L(MV,V,(c+='d',ix))m(x){v)
signal(X/'I',vi[x]);}d(x)char*x;{v)write(i,x,i);}L(MC,V,M+I)xv(){c>=i?m(
c/M/M+M):(d(&M),m(cm));}L(mi,V+cm,M)L(md,V,M)MM(){c=c*M%X;V-=cm;m(ix);}
LXX(){gets(D)||(vi[iv])();c=atoi(D);while(c>=X){c-=X;d("m");}V="ivxlcdm"
+iv;m(ix);}LV(){c-=c;while((i=cc[*D=getchar()])>-I)i?(c?(c<i&&l(-c-c,
"%d"),l(i,"+%d")):l(i,"(%d")):(c&&l(M,")"),l(*D,"%c")),c=i;c&&l(X,")"),l
(-i,"%c");m(iv-!(i&I));}L(ml,V,'\f')li(){m(cm+!isatty(i=I));}ii(){m(c=cm
= ++I)v)pipe(VI);cc=xi+cm++;for(V="jWYmDEnX";*V;V++)xi[*V^' ']=c,xi[*V++]
=c,c*=M,xi[*V^' ']=xi[*V]=c>>I;cc[-I]-=ix v)close(*VI);cc[M]-=M;}main(){
(*vi)();for(;v)write(VI,V,M));}l(xl,lx)char*lx;{v)printf(lx,xl)v)
fflush(stdout);}L(xx,V+I,(c-=X/cm,ix))int(*vi[])()={ii,li,LXX,LV,exit,l,
d,l,d,xv,MM,md,MC,ml,MV,xx,xx,xx,xx,MV,mi};


I hate C.
 
claude_moveml said:
I hate C.
The same level of obfuscation is quite possible in BASIC - and no fair going to a page that contains the winners for obfuscated code in 'C'. 'C' is as obfuscated or as easy to read as you care to make it. Except for some of the operators, 'C' or 'C++' code can be very readible. If you are familiar with the syntax then the operators should be very readable - 'C++' generally more so than 'C' - especially now with optimizing compilers that don't require the coder write obtuse code to eek out the last CPU cycle.

The algorithm is more important anyway; an efficient and proper algorithm will generally be more efficient by orders of magnitude than some little tweak in the code (which may work for one version of one compiler on one machine, but not six months down the line when the compiler or machine changes).
 
Back
Top