dmitry_vk wrote: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.
At least that is one possibility to imagine (and specify) what is being done. I.e., this is the model. The implementation itself is mostly different.yougene wrote:So each used variable has its own stack of possible bindings?
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.
Ok, sorry, "state" is not quite the concept - its about side effects. A let-statement overloads the value of a variable, but does not cause any side effects. See referential transparency for more details on this.yougene wrote:Could you expand on this? Why is let stateless and setf isn't?
It depends on what you mean by "modify". Let overloads bindings of variables for a certain part of the program, without changing the Bindings for anything else. Of course, this modifies what a certain variable name stands for for a clearly defined part of the program code - so it modifies the variable somehow. But it doesnt do anything to the values this variable stands for.yougene wrote:Why have a variable at all if you're not going to modify it?
Yes. Modifying a list means modifying a state. But modifying a list means modifying an object, not modifying a variable - i.e. thats something different.yougene wrote:Would modifying lists be considered modifying a state?
yougene wrote:Could you expand on this? Why is let stateless and setf isn't? Why have a variable at all if you're not going to modify it?
yougene wrote:Would modifying lists be considered modifying a state?
Users browsing this forum: No registered users and 7 guests