3 ms·
In CL without the need for destructuring: (setf (values a b c) (values 10 20 30))
by lispm 10y ago
In CL without the need for destructuring:
(setf (values a b c)
(values 10 20 30))
- icebraining 10y agoThat's still three superfluous words. I have to agree with abritinthebay, especially when comparing with Python's destructuring, which doesn't even need brackets: a, b, c = 10, 20, 30
- lispm 10y agoWhat about all those superfluous commas? I also dislike languages where expressions don't have visible bounds.
- icebraining 10y agoA line break isn't visible? Not by itself, I suppose, but in the code, it's hard to miss.
- lispm 10y agofor what expression does the line break stand, exactly?
- smallnamespace 10y agoBut why must everything be an expression?
- davexunit 10y agoBecause anything else is a language design mistake.
- smallnamespace 10y agoCan you justify that statement empirically?
- 918723192 10y agoa, b, c is a tuple. Parentheses can be omitted, same as in some ML dialects: # let a, b, c = 10, 11, 22;; val a : int = 10 val b : int = 11 val c : int = 22 # a, b, c;; - : int * int * int = (10, 11, 22) # (a, b, c);; - : int * int * int = (10, 11, 22)
- kazinator 10y agoPython needs a piece of whitespace on the left of the correct size and tab/space constituency, and a newline on the right. It's ambiguous. What is the relative precedence of the comma and equal sign? You just have to know. Lisp means never memorizing associativity and precedence tables again.
- icebraining 10y agoNo, just the name and argument order of a bunch of functions/macros (set, setf, setq...).
- smallnamespace 10y ago> never memorizing associativity and precedence tables again. Why is that an unambiguous benefit though? By that logic, we ought to have parentheses around every mathematical expression as well. I think there's a sane middle ground between forcing people to memorize endless precedence tables versus not having any implicit precedence at all.
- kazinator 10y ago> By that logic, we ought to have parentheses around every mathematical expression as well. Yes we should. Some math notations are simply crazy; they make it hard to follow the semantics. The one thing that turns me off math is the notation. A lot of math papers don't explain their notation; that's another problem.
- deleted 10y ago[deleted]
- Macha 10y ago> Python needs a piece of whitespace on the left of the correct size and tab/space constituency, and a newline on the right. Good luck getting your lisp code merged with mismatched tabs/spaces or everything aligned to column 0.
- abritinthebay 10y agoBetter, I wouldn't call it elegant though. But better than other Lisp example in this thread. Though realistically you're destructuring in the same way just with implicit vs explicit structure. Practically speaking there's no difference but CL has a less clear syntax.