4 ms·
That said, it would be nice if lisp used square brackets for this instead. Easier to type on boring old US QWERTY.
by VyseofArcadia 9y ago
That said, it would be nice if lisp used square brackets for this instead. Easier to type on boring old US QWERTY.
- Zelphyr 9y agoRebol and Red are very Lisp like and use square brackets instead of paren's.
- thedirt0115 9y agoNo problem, just a couple reader macros! (Adapted from an answer on https://stackoverflow.com/questions/1988/how-far-can-lisp-macros-go https://stackoverflow.com/questions/1988/how-far-can-lisp-ma...) ;; Make [] == () (set-syntax-from-char #\[ #\( ) (defun lbrace-reader (stream inchar) (declare (ignore inchar)) (read-delimited-list #\] stream t)) (set-macro-character #\[ #'lbrace-reader) (set-macro-character #\] (get-macro-character #\) )) (set-syntax-from-char #\] #\) )
- mikegerwitz 9y agoSome lisps use parenthesis and brackets interchangeably. Some people prefer to strategically alternate them, but you're free to use them exclusively. Guile Scheme, for example: scheme@(guile-user)> [list 1 2 3] $1 = (1 2 3) scheme@(guile-user)> (list 1 2 3) $2 = (1 2 3) scheme@(guile-user)> [car '[1 2 3]] $3 = 1
- eatonphil 9y agoWhile true, this is not officially supported as part of the RnRS standard I believe. They set these characters aside as reserved for future use.
- mikegerwitz 9y agoYes, you're correct. R7RS at least explicitly reserves brackets and braces, and only acknowledges parenthesis in its syntax.
- lispm 9y agoI think this depends on which RnRS you look at.
- ketralnis 9y agoRacket can use either. They are syntactically equivalent, but there are some community norms around when to use each. Racket’s included editor DrRacket takes the [ and ] keys and figures out which to use using those conventions, inserting either [ or ( as appropriate
- krapp 9y agoI'd like to see square brackets replace the backtick. I only have a cursory familiarity with lisps but I constantly find that too easy to miss.
- kuschku 9y agoSquare brackets are AltGr-8 and AltGr-9 on German T2, but Parens are Shift-8 and Shift-9, which is much nicer on the hands. So I’m going to be against this.
- sedachv 9y agoParentheses are so much more frequently typed than square brackets in almost every context that you are better off following the Lisp Machine keyboard layout and swapping them on your keyboard even if you do not program in Lisp: https://news.ycombinator.com/item?id=14985932 https://news.ycombinator.com/item?id=14985932
- ScottBurson 9y agoYes, agreed. From your previous comment: > Apple does not provide a way to do these remappings on OS X Run Emacs (or XEmacs) under XQuartz and you can do whatever remapping you want. This is how I deal with it. Another choice is a fully programmable keyboard, though these also tend to have nonstandard layouts that require some retraining.
- chuchana 9y agoThere is no need for X, you can just use elisp, i.e.: (keyboard-translate ?\[ ?\() And unless you do need X, I suggest using Emacs-Mac-Port instead of of the official Emacs: https://bitbucket.org/mituharu/emacs-mac/overview https://bitbucket.org/mituharu/emacs-mac/overview
- phoe-krk 9y ago$ setxkbmap -option parens:swap_brackets