That is a... Choice.
Breaking the pair operator in favour of something new.
That is a... Choice.
Breaking the pair operator in favour of something new.
https://www.draketo.de/software/wisp
Mind you - I usually end up concluding that Lisp syntax is actually pretty good as it is...
I just never quite manage to grasp the new syntax.
defun multiply-thrice(x):
print(x * x * x)
end
multiply-thrice(23)I can’t opine on whether that’s a good choice. But I will observe two things: first, singly linked lists aren’t as great on modern computing architectures as they were 50 years ago. Locality of reference matters a lot more now. And second, both Hy and Clojure abandoned the traditional focus on dotted pairs, and in both cases I found it was fine. (Disclaimer, I didn’t spend a whole lot of time with Hy.)
Guile uses vectors, for example. [0]
Chicken... Is Cheney, so your list disappears entirely, half the time.
Gambit uses vectors. [1]
[0] https://www.gnu.org/software/guile/manual/html_node/Cheaper-...
[1] https://github.com/gambit/gambit/blob/master/gsc/_back.c#L11...
A simple macro would've sufficed, say:
(compose
sum
(numbers 1 2 3))((. sum numbers) (1 2 3))
But all that gives me a nagging feeling that maybe traditional Lisp macros don't really compose that well? So as a band-aid I had the idea to introduce special infix macros so one could for example do "(if (expr as: var) (something-something var))", or maybe "(something-something var where: var expr)" and so on. I'm not sure what the exact semantics should be though, especially with the as: form. It's probably just a result of doing too much Smalltalk lately, but out of all the "let's fix lisp's syntax" ideas I don't think I have seen exactly this one before, so that's something I guess. (As an alternative we could also of course just replace the lambda form with something less verbose so one could "(if expr [var | something-something var])" and then make the conditionals regular functions, or even generic ones specialized on booleans. Or maybe I'll just get back to hacking my init.el for now and try to cleanse my mind of these impure thoughts.)
Its enabled by default with Guile, for example.
(+ 1 2 {10 * 2} 6)
https://srfi.schemers.org/srfi-105/ (-> [1 2 3] f g)Personally I have mostly sometimes used it with Emacs Lisp, but in general relying too much on plain cons cells and cadring down the cars of their cddars feels like a code smell to me and if I need a pair I can always just use cons? As the (only, I think?) infix operator in traditional lisps it has always felt extra-ordinarily useless to me (outside of Schemes use of it lambda lists), but maybe I'm just missing something.
You should be using the pairs when using make-hash, for example.
Cons also doesn't always return a pair. Its main purpose is for prepending to a list. Only when "the second argument is not empty and not itself produced by cons" does it produce a pair.
Which means '(a . b) is clearer code in intent, than (cons a b).
Deeply nested pair & list constructs that need to be unpacked with complex car/cdr combinations is what IMHO gets messy and I take the appearance of cddar & co in code as a sign that I should start thinking about using proper data structures.
(eq? (pair? '(A . B)) #t)
(eq? (pair? (list 1 2 3)) #f)
But agree you probably want list-ref instead of cddr and friends.