summaryrefslogtreecommitdiff
path: root/notes/let.md
diff options
context:
space:
mode:
authorTaylan Kammer <taylan.kammer@gmail.com>2025-03-29 11:10:24 +0100
committerTaylan Kammer <taylan.kammer@gmail.com>2025-03-29 11:10:24 +0100
commit451aa92846b5fd5c8a0739336de3aa26d741d750 (patch)
tree21e51213bf1d39c2a8677060c51d83a656873786 /notes/let.md
parent5025f9acf31cd880bbff62ff47ed03b69a0025ee (diff)
Relocate MD sources for HTML notes.
Diffstat (limited to 'notes/let.md')
-rw-r--r--notes/let.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/notes/let.md b/notes/let.md
new file mode 100644
index 0000000..4af41bd
--- /dev/null
+++ b/notes/let.md
@@ -0,0 +1,41 @@
+# No shadowing (shock!) and a reduced set of `let` forms
+
+This may be shocking for Schemers but I believe shadowing variables is
+evil. I've already written a bug once that would have been prevented
+had it not been possible to shadow variables, and I don't even write
+that much Scheme code.
+
+And let's face it: The presence of four different forms by the name of
+`let`, `let*`, `letrec`, and `letrec*` is daunting when you're coming
+from another language. Lack of shadowing allows us to reduce this
+without losing out much functionality.
+
+In the absence of shadowing, `let` becomes nearly useless because you
+can always use `letrec` to fulfill the same need; it's strictly more
+powerful. (The only thing `let` can do that `letrec` can't, is to
+refer to the previous binding of a variable before shadowing it.)
+
+Further, the value of vanilla `letrec` is dubious when `letrec*` is
+strictly more powerful. So, in Zisp, `let` is the ultimate binding
+form that does what `letrec*` does in Scheme.
+
+Except it does more! We haven't looked at the whole `let-values`
+family yet. In Zisp, these are also merged into the ultimate `let`,
+using the SRFI 71 syntax:
+
+```scheme
+
+(let ((a (one-value))
+ (b c (two-values))
+ ((values d e . rest) (arbitrary-values)))
+ (do-things))
+
+```
+
+You may be wondering whether it also supports the "let loop" syntax of
+vanilla Scheme `let` and the answer is no, because I hate that syntax.
+It has too high a risk of leading to absolute spaghetti code with no
+clear indication as to how the loop variables are being updated.
+
+If you want to loop, use a dedicated looping syntax! Even `do` is
+better than "let loop" shenanigans if you ask me.