12 ms·
A lisp that didn’t spam parentheses would probably be more palatable.
by LettuceSand12 2y ago
A lisp that didn’t spam parentheses would probably be more palatable.
- FredrikMeyer 2y agoClassic counter-answer: Javascript: f(x). Lisp: (f x). Javascript: f(g(x)) Lisp: (f (g x)) Same amount of parens.
- Timwi 2y agoThis is called “proof by example” and is a fallacy. Show me how to write `a + b * c` in Lisp without parentheses.
- lispm 2y agoOne version would be to actually leave the expression as is and temporarily switch the Lisp reader to Infix. I'm loading an infix reader macro into LispWorks, the code is roughly 30 years old: CL-USER 1 > (ql:quickload "INFIX") To load "infix": Load 1 ASDF system: infix ; Loading "infix" ;;; ************************************************************************* ;;; Infix notation for Common Lisp. ;;; Version 1.3 28-JUN-96. ;;; Written by Mark Kantrowitz, CMU School of Computer Science. ;;; Copyright (c) 1993-95. All rights reserved. ;;; May be freely redistributed, provided this notice is left intact. ;;; This software is made available AS IS, without any warranty. ;;; ************************************************************************* ("INFIX") Now we can write Infix expressions: CL-USER 2 > '#I( a + b * c ) (+ A (* B C)) Let's set the variables a, b, c CL-USER 3 > setf a 10 b 20 c 30 30 The Infix expression reader macro at work: CL-USER 4 > #I( a + b * c) 610 Inside the Infix macro Lisp parses a sublanguage of Infix expressions into Lisp s-expressions. Generally this would be possible with a normal macro, but the reader also changes the tokenizing of elements, so we can also write: CL-USER 5 > #I(a+b*c) 610 In "normal" Lisp syntax a+b*c would be a single symbol. The infix reader parses it into five symbols and a list according to operator priorities.
- solanav 2y agoCheck out Julia (https://discourse.julialang.org/t/about-julia-and-lisp/25119 https://discourse.julialang.org/t/about-julia-and-lisp/25119)
- cess11 2y agoIt's not uncommon in the Lisp-family that you can use [] as well as () so that problem of yours is solved already.