Re: S-expressions
Aaron Optimizer Digulla <[email protected]> Thu, 7 Aug 2003 00:03:25 +0200
| Newsgroups | gmane.comp.programming.pragmatic |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 06, 2003 at 10:54:17PM +0200, Lieven Marchand wrote:
> > 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)
So I can (setf a b)? What's wrong with a=b?
> * 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
Ok, this is a very good example because I didn't understand it :-)
> (loop for i from 0 below 10
That is probably for i = 0 to 10.
> for j across string
uhm... iterate over every character of the string?
> for key being each hash-key of hash-table
python would say here
for key in hashTable.keys():
Which is easier to understand?
> sum i into account
?? account += i or what?
> collect j into stack
????
> when (eql key :foo)
> do
> (push (get-hash key hash-table) stack)
> finally (return (values account stack)))
argl...
Ok, this seems to be a while look (while key == :foo). What does the ":" mean?
Then we seem to have the body of the loop (do(...)).
What happened to the "Professionals read the code by indentation"
when the code is not indented??? :-)
Ok, next statement is a push (something) on stack. I guess that the loop
pushes all elements where the key is larger than ":foo" into stack.
As a result, the values of "account" and "stack" are returned.
But the code confuses me completely:
- Why is there a "(" before push but none before "for", "sum",
"collect", "when" and "finally"??
- Where does a statement begin and where does it end? Is the second
for part of the body of the first for?
> 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.
Python, C++ and Java have iterators, too.
My whole point is:
- The infix syntax is hard to read if the language doesn't
enforce indentation because you have to manually count
the parens to know what belongs where.
- 90% of all software developers are not used to it
- Recursive structures in the code confuse people. Many people
don't understand how quicksort works and that's one of
the most simple sorting algorithms.
- Computers can count parens if they like but people have
better things to do.
So if S-expressions don't have any great advantage for 80% of the *users*
of the language, then scrap them.
Note: Autoconf uses M4 which uses a similar approach and people
complain all the time how horrible it is to write macros for
that.
Maybe SEs make macros are easier to handle for the language designer
but upto now, you have failed to make me see one, single advantage
of them.
--
==============================================
Sowatec AG, CH-8330 Pfäffikon (ZH)
Witzbergstr. 7, http://www.sowatec.com
Tel: +41-(0)1-952 55 55
Fax: +41-(0)1-952 55 66
----------------------------------------------
Aaron "Optimizer" Digulla, [email protected]
==============================================
------------------------ 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/