Re:Janet: a lightweight, expressive and modern Lisp
by frankpf on Wednesday May 13, 2020 @11:25AM
(#23167779)
I don't use lisp languages, but one basic difference this has from other lisps is that functions accept multiple expressions, e.g.:
In other lisps, you'd have the last expression nested inside a `let` block:
which makes the code hard to read and edit IMO. Languages like Haskell and OCaml suffer from a similar problem too.
[ Parent
| on HN ]
Re:Janet: a lightweight, expressive and modern Lisp
by nathcd on Wednesday May 13, 2020 @11:34AM
(#23167891)
> which makes the code hard to read and edit IMO. Languages like Haskell and OCaml suffer from a similar problem too.
That's interesting, I've always really loved the "return last expression in a block" syntax. (Ruby and Rust can be added to your list as well.) That syntax just reads really naturally to me.
Re:Janet: a lightweight, expressive and modern Lisp
by frankpf on Wednesday May 13, 2020 @11:46AM
(#23168054)
I like that too, but both Rust and Ruby allow multiple expressions/statements before the last expression. In Haskell and OCaml IIUC you need to use things like `let x = ... in <expr>` or `<expr> where x = ...`, so you still have a single expression in function bodies.
Re:Janet: a lightweight, expressive and modern Lisp
by lispm on Wednesday May 13, 2020 @02:55PM
(#23170345)
Common Lisp:
(defun greet (firstname lastname &aux fullname)
(setf fullname (format nil "~a ~a" firstname lastname))
(format nil "Hello, ~a" fullname))
Re:Janet: a lightweight, expressive and modern Lisp
by thayne on Wednesday May 13, 2020 @11:33AM
(#23167877)
In common lisp `defun` does not require using `let`.
Re:Janet: a lightweight, expressive and modern Lisp
by junke on Wednesday May 13, 2020 @04:55PM
(#23171737)
There are two things at play here (1) the implicit body and (2) being able to add new bindings in an existing scope with "def".
CL has an implicit body, but does not allow defining new bindings outside of some dedicated forms (let, etc.). I really prefer having to write "let" forms instead of having new variables added inside the body.
Re:Janet: a lightweight, expressive and modern Lisp
by threatofrain on Wednesday May 13, 2020 @11:32AM
(#23167854)
in Racket you can do it either way, and perhaps these sorts of issues should just be solved with an auto code formatter?