Replies: 3 comments
-
Fun fact, you actually can use parens for the arguments array if you want to 🤪 Janet 1.33.0-f91e5994 linux/aarch64/clang - '(doc)' for help
repl:1:> (defn echo (token) (print token))
<function echo>
repl:2:> (echo "Hello, world")
Hello, world
nil |
Beta Was this translation helpful? Give feedback.
-
Oops, I guess @CFiggers was faster (^^; I don't have an answer to your question, but if you really must, I think you can use parentheses:
It looks like there are some folks who've discussed why square brackets are used in the way mentioned above for Clojure: |
Beta Was this translation helpful? Give feedback.
-
I don't know an official reason but I think the square bracket version is easier for me to parse because of the following heuristic that works most of the time: Whenever you see round parens, the first element is significant in some way (it's treated or interpreted or behaves differently from the remaining elements). Whenever you see square brackets, all elements in the brackets are on equal footing. In The scheme-style Like (This argument falls apart a little because the function argument list supports a couple pieces of syntax that don't work in regular list destructuring, like (Also this is also a little undercut by the fact that Janet allows you to write |
Beta Was this translation helpful? Give feedback.
-
First, ty for janet-lang. It's neat to explore although I don't exactly yet know where I might use it.
Like clojure and unlike various lisps and scheme, janet uses brackets for function argument delimiters, e.g.
(defn echo [token] (print token))
. I found this jarring in clojure and find it jarring here. Yes, it's just syntax and yes, I should just get over it. But I've never really understood the design choice so I'll ask here now: why?Beta Was this translation helpful? Give feedback.
All reactions