Re: S-expressions

Lieven Marchand <mal-x0HW/[email protected]> 06 Aug 2003 22:54:17 +0200
Newsgroups gmane.comp.programming.pragmatic
Message-ID <[email protected]>
Aaron Optimizer Digulla <[email protected]> writes:

> On Wed, Aug 06, 2003 at 05:07:19PM -0000, Eric Merritt wrote:
> 
> > How many of you out there actually have a problem with s-expressions? For those 
> > of you that do not know s-expressions imply a lisp like syntax, ie 
> >  
> >  (some-fun arg2 arg2) 
> >  
> > The reason I ask is becuase s-expressions make quite a bit of the langauge 
> > design easier. Macros become fairly simple, extensions integrate well etc. I tend 
> > to lean to this side of things. However, I am not the only one interested in this 
> > project. 
> >  
> >  So an open question, do you have a dislike of s-expressions and if so why? This 
> > is a chance to make yourself heard. 

I write mostly Common Lisp these days so I'm with you.

> I have never used s-expressions but I don't like the syntax.

Give it a try some day.

> The lisp/scheme syntax always looked very strange for me because of
> the enormous amount of parens. I felt it always hard to match them
> and to understand which arguments belonged together, etc.

You don't match them. Experienced lisp programmers read programs by
indentation.

> Then, what exactly does this make easier? It might be easier to
> parse (a (b (c (d (e f g h ))))) but so what? I don't care how complex
> some code is to parse *as long as it is simple to read for a human*.

It makes macros feasible. See below. A system with macros with
comparable power to CL has been done for an infix language in Dylan
but it's significantly more complex.

> Also a note about macros: When I do C, I need macros. The language
> is just so limited in what it can do without.
> 
> When I do Java, I wished I had a preprocessor. And hey, Java 1.5 will
> have something like that. Makes me wonder, why ;-)
> 
> When I do Python, I never missed macros.
 
[ snip feature list ]

> May I suggest that you have a very close look at Python? :-)

May I give you a few examples of existing Lisp macrology?

* generalized assignment (the setf macro)

* one of the most advanced object systems (CLOS) could be build as a macro 
layer on existing lisp systems. In fact, today this system is being reinvented 
in the Java world as aspect oriented programming.

* the LOOP macro

this was an experiment in coding a more algol like iteration statement.

It allows you to write stuff like

(loop for i from 0 below 10
      for j across string
      for key being each hash-key of hash-table
      sum i into account
      collect j into stack
      when (eql key :foo)
      do
      (push (get-hash key hash-table) stack)
      finally (return (values account stack)))

Further, if you have your own data structure, say a graph, you can
tell loop about it with add-loop-path and then you can use 'for edge
being each edge of graph' as a loop clause.

* the series experiment (series.sf.net) which was an attempt to have a 
declarative approach to iteration compile into the same code as an efficient 
hand coded iteration.

-- 
Jane - Daria? Come on, the neighbors are starting to talk.
Daria - Um... good. Soon they'll progress to cave drawings and civilization 
will be on its way.

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/W4wwlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
pragmatic_lang-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/