I understand what let does and what scope is, but thanks for the feedback.
My question was about how to program without side effects. Whether properly programming in lisp is simply a matter of maintaining referential transparency.
Search found 23 matches
- Sun Jan 31, 2010 2:22 pm
- Forum: Common Lisp
- Topic: Why have the let function when you already have setf?
- Replies: 16
- Views: 17362
- Sun Jan 31, 2010 11:32 am
- Forum: Common Lisp
- Topic: Why have the let function when you already have setf?
- Replies: 16
- Views: 17362
Re: Why have the let function when you already have setf?
Is it possible to use setf without side effects if it's used to only modify variables passed in as parameters or generated within the function?
Is that how you write good lisp code?
Is that how you write good lisp code?
- Sun Jan 31, 2010 11:29 am
- Forum: Common Lisp
- Topic: Are ALL S-Expressions really ordered pairs?
- Replies: 7
- Views: 7025
Re: Are ALL S-Expressions really ordered pairs?
I've been using that book as well, thanks for the input. Yeah, I think I get it now. Seems like lisp forms are structurally isomorphic to the abstract syntax tree which is structurally isomorphic to the S-Expression notation which is structurally isomorphic to the linked-list/tree data structure. I ...
- Sat Jan 30, 2010 4:55 pm
- Forum: Common Lisp
- Topic: Why have the let function when you already have setf?
- Replies: 16
- Views: 17362
Re: Why have the let function when you already have setf?
Let is stateless, while setf explicitly modifies a state. This can make a huge difference for example when working with multiple threads. In general, it is good practice to try to make code stateless, and only introducing states where it is really necessary. Could you expand on this? Why is let sta...
- Sat Jan 30, 2010 4:46 pm
- Forum: Common Lisp
- Topic: Why have the let function when you already have setf?
- Replies: 16
- Views: 17362
Re: Why have the let function when you already have setf?
So each used variable has its own stack of possible bindings?
- Sat Jan 30, 2010 3:12 pm
- Forum: Common Lisp
- Topic: Are ALL S-Expressions really ordered pairs?
- Replies: 7
- Views: 7025
Re: Are ALL S-Expressions really ordered pairs?
mmm, maybe (+ 1 2) is syntactic sugar for (+ (1(2))?
- Sat Jan 30, 2010 2:45 pm
- Forum: Common Lisp
- Topic: Why have the let function when you already have setf?
- Replies: 16
- Views: 17362
Re: Why have the let function when you already have setf?
First of all, let and setf are not functions. let and setf are completely different things. setf is a generic assignment operator - it assigns values to "generic places". let is a special form that creates lexical or dynamic variable bindings. I'm not quite grasping the difference yet, bu...
- Sat Jan 30, 2010 2:43 pm
- Forum: Common Lisp
- Topic: Are ALL S-Expressions really ordered pairs?
- Replies: 7
- Views: 7025
Are ALL S-Expressions really ordered pairs?
http://www-formal.stanford.edu/jmc/recursive/node3.html An S-expression is then simply an ordered pair, the terms of which may be atomic symbols or simpler S-expressions. But it seems like functions are able to take as many parameters as they like. Is this a convention that never carried over into ...
- Sat Jan 30, 2010 12:18 pm
- Forum: Common Lisp
- Topic: Why does taking out nil break this code segment?
- Replies: 10
- Views: 11515
Re: Why does taking out nil break this code segment?
It all makes sense now, thanks guys.
I find cond's nicer to work with, but I still find myself visualizing the code as nested if statements. It's a fun challenge though.
I find cond's nicer to work with, but I still find myself visualizing the code as nested if statements. It's a fun challenge though.
- Sat Jan 30, 2010 12:14 pm
- Forum: Common Lisp
- Topic: Why have the let function when you already have setf?
- Replies: 16
- Views: 17362
Why have the let function when you already have setf?
Am I missing something here?
let can define a list of variables and setf can't( as far as I know ). Other than that I see no difference. Is this correct?
let can define a list of variables and setf can't( as far as I know ). Other than that I see no difference. Is this correct?