Page 1 of 1

let

Posted: Tue Nov 18, 2003 7:04 pm
by eddier
I wonder about replacing the current (let function syntax

Code: Select all

(let ((variable1 expression1) (variable2 expression2) ... (variable n expression n))
  body)
with

Code: Select all

(let variable1 expression1 variable2 expression2 ... variable n expression n
  body)
as with the (if function.

Eddie

Posted: Tue Nov 18, 2003 10:50 pm
by Lutz
how would you distingush from the body expressions (could be various)? or do you mean:

Code: Select all

(let (var1 ex1 var2 ex2 ..) 
    (body-exp1) (body-exp2) ...)
The pretty printer then would do a line break and indent after the local list:

Hans-Peter, what is AutoLisp doing?

Also while at saving ((())), what about 'dolist' and 'dotimes'

Code: Select all

(dolist x lst
   (body-exp1)
   (body-exp2) ...)
What will all the users say? (it would be fine with me)


Lutz

Posted: Wed Nov 19, 2003 6:38 am
by HPW
Hm, Autolisp does not have a let.

But my vote would for the current syntax or Lutz's version. It keeps the structure in larger sources. A good editor can jump to the closing paranthesis.

Posted: Wed Nov 19, 2003 6:01 pm
by eddier
Yes, I meant

Code: Select all

(let (var1 ex1 var2 ex2 ..)
    (body-exp1) (body-exp2) ...) 
I guess less or more parenthesis are a matter of personal taste no offense HPW. I was looking at consistency.

For example:

Code: Select all

(setq var1 exp1 var2 exp 2 ... var n exp n)
and then there is

Code: Select all

(let ((var1 exp1) (var2 exp 2) ... (var n exp n))
 ...)
Eddie

Posted: Wed Nov 19, 2003 6:04 pm
by HPW
>Therefor my vote would for the current syntax or Lutz's version.

So no problem! :-)

It is Lutz's version.

Posted: Wed Nov 19, 2003 7:12 pm
by eddier
Agreed! It is definately Lutz's version! :-)

BTW the new nth, set-nth, push, and pop functions are really proving themselves useful. I have reduced a lot of complex code in my survey tabulating routines with these functions. Now the routines are much more amendable to corrections and added future functionality.

Thanks Lutz!

Eddie

Posted: Wed Nov 19, 2003 8:08 pm
by Lutz
I am glad the new multi dimensional functions prove to be useful, I think they bring a whole new dimension (pun intended) of power to newLISP.

I just finished a small modification to 'let', which lets you use both syntaxes: the classic one and the one suggested by Eddie:

(let (var1 ex1 var2 ex2 ..)
(body-exp1) (body-exp2) ...)

'dolist' and 'dotimes' will stay how they are, they are really similar to the new form of 'let' : (keyword (parameters) body) and like in 'let' their parameter symbols are local. So suddenly everything makes sense.

This will be in 7.3.8 (weekend development release). In that version you can also use both 'fn' and 'lambda', which makes for shorter anonymous functions i.e:

(map (fn (x) (< x 100)) a-list) ; filters values < 100 from a-list
(map (lambda (x) (< x 100) a-list) ; same thing, classic syntax

work both the same, but the first one is a lot more readable and 'fn' is a commonly used abbreviation for anonymous function. I got this idea from Paul Graham on his Arc language project.

Lutz

Posted: Wed Nov 19, 2003 9:07 pm
by eddier
Your work is much appreciated!

Eddie