libera/#commonlisp - IRC Chatlog
Search
10:12:23
cpli
i.e. i can replace this and only this with something less mind-numbing (LET ((A (F))) (LET ((B (G A))) (LET ((C (H B))) ; ...
10:13:55
cpli
i.e. discrete. it seems strange to me that when LET is taught as "simultaneous" bindings that one would cast away the direct structure in favor of 2 spaces of indentation
10:14:30
beach
Indentation is not the argument. It is the argument that splittist gave, and that I repeated.
10:16:02
cpli
you argue (LET* ((THING (PREPARE-THING)) (FIELDA (GET-FIELDA THING)) (FIELDB (GET-FIELDB THING))...
10:18:11
cpli
in my opinion: (LET* ((THING (PREPARE-THING)) (FIELDA (GET-FIELDA THING)) (FIELDB (GET-FIELDB THING)) ;.. omitted
10:18:24
beach
For that case, it depends on how many "fields" you have, so either (let ((thing ...)) (let* ((fielda ...) (fieldb ...)) ...)...), or a big LET* if you have few "fields".
10:18:57
cpli
casts away the direct dependency all notion of dependency of FIELDA, FIELDB, .. to THING
10:19:58
cpli
beach exactly not LET* in the former case. FIELDA, FIELDB, etc all depend only on THING
10:21:15
cpli
if people don't care about expressing the relationships between bindings in LET*, then why have LET
10:23:32
splittist
A little bit of sequential processing in a LET* is OK. If it gets too long, a macro might make the intention clearer, eg. something like ~> for purely sequential processing or a special destructuring macro if that's what you're doing (or not bother destructuring)
10:23:42
jackdaniel
cpli: (let ((x1 (round x1)) (x2 (round x2)) (real-dist (round (- x2 x1))) ...) has quite a different meaning from when you use let*
10:26:06
beach
cpli: People do care which is why LET exists, and LET* is used pretty much only in the sequential case. I think that's what I have been saying.
10:26:59
beach
cpli: The default is LET when it works, for the reason that splittist said. It signals to the person reading the code that there are no dependencies between the bindings, so the person does not have to verify that.
10:27:19
jackdaniel
cpli: just use your aesthetics sense to decide what looks better - I think that there are more interesting dillemas when writing programs ;p /me gets back to more interesting dillemas
11:12:31
_death
when I see a LET* (used according to the convention) it evokes a stronger sense of opportunity to re-factor
16:12:23
beach
Different question: Say we have (let* ((x ...) (y ...)) (declare ... x)...) and suppose the initialization form for y references x. Does the scope of the declaration include the initialization form for y? And if so, where in the standard does it say that?
16:15:37
beach
The scope of a bound declaration is the same as the lexical scope of the binding to which it applies.