ouphe wrote:One more thing: assuming my (admittedly amateur) problem should ever occur, which of the two examples would be better coding practice (using let* instead of let in the second, of course)?
Well, "better" depends upon what your goals are. Are you aiming for faster execution, fewer memory resources, et cetera?
In my opinion, the "better" coding practice is generally the one that more accurately reflects what is being modeled or, in other words, the form that is most "readable". Of your examples, I am thinking that the latter one is probably "better"; assuming that "(+ a 1)" is in and of itself a meaningful entity.
By way of example, I would submit that the first of the following forms is more understandable to anybody who is reading the code. In fact, if you were to use the second form (for reasons of speed or size optimization) then it would be extremely advisable that you add a comment block describing where "800" comes from and explaining why you wrote the code the way you did.
- Code: Select all
(let* ((line-width 80)
(line 10)
(char-offset 5) )
(+ (* line-width line) char-offset) )
(let* ((location 800)
(char-offset 5) )
(+ location char-offset) )