lexer puzzle

b.i.mills at massey.ac.nz b.i.mills at massey.ac.nz
Fri Sep 26 09:20:10 EDT 2003


Hi,

> Haskell to me seems to be a great language with a syntax problem, 
> and a bad case of too many ways to do the same thing; thus every 
> programmer does things their own way and it's difficult to grasp 
> the language by looking at examples.

int fact(int x){int t=1; while(x) t*=x--;}

int fact(int x){int t=1; for(int i=1;i<=x;i++) t=t*i;}

int fact(int x){if(x=0) return 1; else return x * fact(x-1);}

int fact(int x){return aux(x,1);}
int aux(int x, int t){ return x ? t : aux(x-1,t*x);}

int fact(int x){int t=1; while(x && (t*=x--)); return t;}

#define TRUE 1
#define FALSE 0

int fact(int x)
{
 if((x==0)==TRUE) 
  return 1;
 else
  {
   t = fact(x-1);
   return(t*x);
  }
}


x = x + 1;

x += 1;

x++;

#include <stdio.h>
main(t,_,a)
char *a;
{
return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):
1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \
}'+}##(!!/")
:t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1)
:0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
"!ek;dc i at bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);
}


I'm not being facetious here, but deadly serious. 

Your average language that is worth anything allows programmers
to program in more than one way. If the language truely constrained
everyone to produce a given program looking exactly the same way,
then it is probably a nightmare to program in. Speaking as someone
who comes from a C/C++/Java/Scheme/Assembler/Algebra background, 
I don't find Haskell syntax to be any more annoying than any other
typical syntax. And I did not find any particular clash with `.'

It's like the the game of Go, the rules (syntax) you learn in one
sitting, but the strategy can take a life time. Any programmer 
should be able to pick up a new syntax in a week. (not that you
want to do that every week, because you want to get down to 
playing the game).

Regards,

Bruce.

Institute for Information and Mathematical Sciences
Massey University at Albany,
email: B.I.Mills at massey.ac.nz
web: http://www.massey.ac.nz/~bimills



More information about the Haskell mailing list