OT: Ultimate Language Syntax Cleanness Comparison

holger krekel pyth at devel.trillke.net
Mon Feb 10 19:53:21 EST 2003


Kaz Kylheku wrote:
> holger krekel <pyth at devel.trillke.net> wrote in message news:<mailman.1044895117.5567.python-list at python.org>...
> > Jeremy Fincher wrote:
> > > holger krekel <pyth at devel.trillke.net> wrote in message news:<mailman.1044877956.27600.python-list at python.org>...
> > > > If so can you send the snippet which parses *any* perl script? 
> > > > If your deduction above is true, then it should be easy.
> > > 
> > > You originally claimed, "All the methods involve evaluating/executing
> > > it at the same time."  I showed you that Perl's abstract syntax tree
> > > (which is constructed by the code generated from perly.y in addition
> > > to some other arcane machinery) is absolutely different from the
> > > bytecode (an example of which is shown in bytecode.pl), which is
> > > actually executed.
> > 
> > That sharp distinction is still a claim.  Pointing to some files 
> > doesn't prove your point but example code does.  In python i do
> > 
> > >>> import compiler
> > >>> p=compiler.parseFile('test.py')    
> > >>> p                                    # Parse tree
> >  Module(None, Stmt([Printnl([Const('hello world')], None)]))
> > >>> p.filename='test.py' # fixup
> > >>> c=compiler.pycodegen.ModuleCodeGenerator(p).getCode()
> > >>> c
> >  <code object <module> at 0x828a720, file "test.py", line 2>
> > >>> exec c
> >  hello world
> > >>>
> 
> In Lisp, we do:
> 
>   (defvar *s* (with-open-file (f "foo.lisp") (read f)))
> 
>   *s*  ==>  (write-line "hello") 
>   ;; the ``parse tree'' looks exactly like what is in foo.lisp
> 
>   (defvar *c* (compile nil `(lambda () ,*p*))
> 
>   *c*  ==>  #<compiled-closure ...>
> 
>   (funcall *c*)
>   hello
> 
> Note the big differences.

I tried to follow your explanation but know less lisp than
perl, unfortunately.  Still your explanations made sense, thanks.

> ...

> We now return you to the previously scheduled Perl bashing.

But i do wonder what you read out of my posts.  (I have 
intensively programmed perl for one year each day, btw).
It started when i said how surprised i was to find out
that it is apparently not easy to parse perl. 

And i surely didn't indicate that any other current
language had this problem (if it is really there). 

    holger





More information about the Python-list mailing list