Hacker News new | past | comments | ask | show | jobs | submit login

Can you elaborate? I like the extra context that square brackets give.



I just find it inconsistent. Lisp is (at least nominally) about processing lists, so I don't know why the list (foo bar baz) has to be different in:

  (if bar
      (foo bar baz)
      baz)
When contrasted to:

  (define-function quux [foo bar baz]
    ...)
If you use square brackets [x y z] as shorthand for round brackets (vector x y z), that's fine, but don't use them for basic syntactic elements.


I find square brackets quite useful for some kinds of expressions, that have multiple cases or branches. To make a visual difference there can help with readability.


I also find square brackets useful for other kinds of expressions, like Python-style list comprehensions. Though such syntax predates Python, e.g. there's a paper from 1991 https://3e8.org/pub/scheme/doc/lisp-pointers/v4i2/p16-lapalm... whose code still works in Common Lisp. If the language doesn't mandate that square brackets mean something, as Clojure does, then I can make them mean what I want that is convenient for my namespace, as Common Lisp allows. Whether that's data literals or special syntax or something like [x (x <- xs) (oddp x)] to filter out odds, it's nice to have that choice.


I use rainbow delimiters (colourful brackets) for that, but I can accept square brackets as an alternative for people who have issues with colour perception.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: