3 ms·
> SETQ is def At first I said "what" out loud, since SETQ doesn't create bindings, it only updates them then I read the doc (https://janet-lang.org/docs/bindin
by a-french-anon 5mo ago
> SETQ is def
At first I said "what" out loud, since SETQ doesn't create bindings, it only updates them then I read the doc (https://janet-lang.org/docs/bindings.html https://janet-lang.org/docs/bindings.html) and the author is indeed wrong ("bindings created with def are immutable"). He probably meant "SETQ is set".
I really want to like Janet, as it seems to be the sweet spot between Guile, Tcl and CL (minus the speed/maturity of SBCL) but I have a visceral reaction to square brackets (so vectors) being used in lambdas and control flow operators. Same as Clojure, I simply can't get over it. Maybe I will with enough effort?
Also, what's the current LSP/SLIME status? Really important these days.
- nlitened 5mo agoSquare brackets’ use is very consistent and rather logical in how they are used in Clojure’s syntax. When round brackets are used, the first element in the list defines how the rest of the list is interpreted, for example: (func a b c) — run a function with its parameters (macro x y z) — expand a macro with its parameters ([p q r] …) — “bare” function body that starts with a vector of parameters, and executable forms follow. Square brackets are used where elements are the same “kind”, and the first one is not special, e.g.: (defn f [a b c] …) — a collection of same-kind parameters, the first parameter is not special (let [a 1 b 2] …) — a collection of bindings, the first binding is not special The only exception that comes to mind is grouping multiple matching elements in `case`, but it for ergonomics. Once I got the logic, when which is used, I changed my mind, and ever since I’ve felt it’s beautiful.
- a-french-anon 5mo agoThanks a lot, that's a very interesting way of seeing it.
- aquariusDue 5mo agoHuh, now it makes more sense for me too. Thank you!
- veqq 5mo agoYou can... just not use square (and curly) brackets. Instead of `[1 2 3]` just write `(array 1 2 3)`. Instead of `(fn [x] (+ 1 x))` just write `(f (x) (+ 1 x))`. They are never necessary.
- BoingBoomTschak 5mo agoHuh! So like some Schemes and Racket? Yet I must read them in code that isn't mine, which is a large part of the problem.
- xigoi 5mo agoNot quitek in Scheme, parens and brackets are completely interchangeable.
- iLemming 5mo ago> I have a visceral reaction to square brackets Once you understand how destructuring works in Clojure, it then becomes obvious what role square-brackets play.