Re: S-expressions

Aaron Optimizer Digulla <[email protected]> Thu, 7 Aug 2003 20:32:19 +0200
Newsgroups gmane.comp.programming.pragmatic
Message-ID <[email protected]>
On Thu, Aug 07, 2003 at 07:54:52PM +0200, Lieven Marchand wrote:

> > > * generalized assignment (the setf macro)
> > 
> > So I can (setf a b)? What's wrong with a=b?
> 
> The generalized part. a[i][j][k] is written in Lisp as (aref a i j k)
> and to set that element you do (setf (aref a i j k) b). Hash table
> lookup is done as (get-hash key hash-table) and setting one is done as
> (setf (get-hash key hash-table) b). Now suppose I have a function
> (circumference triangle). I can define
> 
> (defun (setf circumference) (new-circumference triangle)
>    ; scale sides so circumference is new-circumference
> )
> 
> and then I can do (setf (circumference triangle) 1)

So that assigns the value 1 to "circumference triangle"?
Besides the nice feature that variables in lisp can contain
spaces in their names, what is the big advantage?

> > > * 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 :-)
> 
> Once again, the point was that a macro (in the original MIT
> implementation a macro of some 10000 lines of code) can change a
> parenthesis rich language like Lisp into something algol like.

But the code is still as unreadable as before ... see below.

> > > (loop for i from 0 below 10
> > 
> > That is probably for i = 0 to 10.
> 
> from 0 to 9 inclusive. otherwise it would be from 0 to 10

Sorry, my bad :-)

> > >       for j across string
> > 
> > uhm... iterate over every character of the string?
> 
> yes
> 
> > >       for key being each hash-key of hash-table
> > 
> > python would say here 
> > 
> >     for key in hashTable.keys():
> > 
> > Which is easier to understand?
> 
> Assuming this isn't rhetorical, I'd say both are about as easy.
> What does python do for the following: 
> 
> for key being each hash-key of hash-table using (hash-value value)
> 
> where it will iterate with key bound to the key and value bound to the value

    for key, value in hashTable.items():
	...

(items() in a hashmap returns an iterator which returns all
key-value pairs as tuples in this context).

Again, I stubbornly claim that my code is easier to understand
for 90% of all programmers who never had contact with this
language.

> > 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"??
> 
> because for the body one drops again into native lisp.

I translate this as "if you can't compile the code in your
head, you can't write it".

> > - Where does a statement begin and where does it end? Is the second
> > for part of the body of the first for?
> there is one iteration. All variables are iterated parallel.

I see. So in the body, I can see the same "i", "j" and all the other
variables change with every iteration?

> > 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.
> 
> Stuff you're not used to is hard to read. Film at 11.
> 
> > - 90% of all software developers are not used to it
> 
> 100% of all software developers won't be used to our new
> language. Maybe we should redesign Visual Basic?

We should avoid the mistakes of the past. My impression was
that Pragmatic should be a language for the masses and not
to prove how unreadable a language can be by design ;-)

The point is that you are arguing "A minority of people
are comfortable with the Lisp syntax. Let's make everyone
else suffer!"

I can understand that being part of a minority (which feels
that they are doing things better than everyone else) is a
pain; I've been an Amiga user and I felt the same. We had
proper multitasking and multimedia before everyone else knew
what that was.

But in the end, if you want to sell something (even for free),
then you must produce something that the customer *wants*.
The customer is used to infix syntax so infix he wants and
infix he gets.

> 
> > - 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.
> 
> Make a tool designed for an idiot and only an idiot will want to use
> it.

Well, everyone can make things complicated but it takes a genius
to make them simple. If we can't design a better language than
all those which already exist, then why bother the world with
another (designed) failure?

-- 
==============================================
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/