5 ms·
“Lisp dialects” is as if one talk about “dialects of curly braces languages”. I would argue that Python is closer to Scheme than Common Lisp is.
by Blikkentrekker 6y ago
“Lisp dialects” is as if one talk about “dialects of curly braces languages”.
I would argue that Python is closer to Scheme than Common Lisp is.
- kazinator 6y agoUntil you write a procedure that walks a structure using cons/car recursion, ha. :)
- Blikkentrekker 6y agoThat happens in so many languages bar the name and even in some Lisps they aren't called that. Even in Common Lisp, the names typically used are “first” and “rest”, not “car” and “cdr”
- phoe-krk 6y agoI must disagree. I see a lot of CAR and CDR calls in code that I see daily. Also, it's a style error to use FIRST and REST when one operates on cons cells, because those imply a different meaning - that one operates on lists. Sure, the language doesn't care whether you use CAR or FIRST, but the programmer does - and they might know that you treat a cons cell as a pair unto its own, rather than an element of a linked list.
- kazinator 6y agoFeel free to substitute the Python version of getting the first and rest of a list (well, the array that Python calls a list). My comment is not about names, but semantics.
- Blikkentrekker 6y ago`list[0]` and `list[1:]`? Almost any language has convenient ways to get the first element of a sequence, and all but the first, even C, this is not unusual at all to lisps.
- kazinator 6y agoBut car and cdr in Lisp and Scheme only retrieve values; they do not copy any aggregate object. When was the last time you saw recursion on list[0] and list[1:] in a production Python program, or even a tutorial?
- Blikkentrekker 6y ago> But car and cdr in Lisp and Scheme only retrieve values; they do not copy any aggregate object. That's because lists are mutable in Python. Do it on tuples and they retrieve and do not copy. Of course in C, one can simply do `ptr[0]` or `ptr+1` which also only retrieves. > When was the last time you saw recursion on list[0] and list[1:] in a production Python program, or even a tutorial? That is purely a difference of culture, not of what the language facilities, both Scheme and Python allow either style.
- lhjn 6y agoLists are mutable in CL
- Blikkentrekker 6y agoThat would be another thing then where the two Lisps are very far apart, and Python is closer to one of them. Lists are not mutable in Clojure, they are “technically mutable” in R6RS Scheme, but it requires opening up a specific module that many Scheme implementations do not even provide unless compiled with specific flags.
- ska 6y agopython really isn't that close to scheme in any practical and theoretical way, even if it has half heartedly embraced lambdas, and has a usable REPL.
- Blikkentrekker 6y agoIndeed it isn't, and it's still closer than Common Lisp is to Scheme. Common Lisp's evaluation semantics are a language of it's own practically at this point and are very far removed form most languages. Scheme is of course very unusual, due to it's including the very unusual `call/cc` primitive operator.
- ska 6y ago> Indeed it isn't, and it's still closer than Common Lisp is to Scheme. On this we disagree.
- Blikkentrekker 6y agoExplain why? What is it that Common Lisp and Scheme have in common aside from the syntax that Python doesn't?
- ska 6y agoOk; One thing that makes this not obvious is that common lisp is a huge language, and scheme is a small one. And since common lisp is multiparadigm, you can work with it in ways that are very much not not like scheme. But you can also use a subset with a very similar paradigm. Some of it is philosophical I suppose. Fundamentally they are both lisps. Both opinionated about what that means, but they are lisps. The fundamental objects in the language are congruent. I find them quite similar for REPL driven exploratory design, in a way that python never quite gets. Although there is a deep schism on macro hygiene, they both have deeply integrated macros. They both allow for clean functional approaches and deep recursion in practice. Both get low level enough to get decent performance from the language itself (unlike python). I guess what I'm saying is I can write CL code that feels very scheme like in approach and also is comfortable in the language. The same is not close to true of python.