let

Started by eddier, November 18, 2003, 11:04:15 AM

Previous topic - Next topic

eddier

let
I wonder about replacing the current (let function syntax



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


with



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


as with the (if function.



Eddie

Lutz

#1
how would you distingush from the body expressions (could be various)? or do you mean:



(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'

(dolist x lst
   (body-exp1)
   (body-exp2) ...)


What will all the users say? (it would be fine with me)





Lutz

HPW

#2
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.
Hans-Peter

eddier

#3
Yes, I meant



(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:

(setq var1 exp1 var2 exp 2 ... var n exp n)

and then there is

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


Eddie

HPW

#4
>Therefor my vote would for the current syntax or Lutz's version.



So no problem! :-)



It is Lutz's version.
Hans-Peter

eddier

#5
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

Lutz

#6
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

eddier

#7
Your work is much appreciated!



Eddie