3 ms·
You're right that the features he mentioned seemed to not be terribly unique to Lisp. But note that your claim wasn't really true before Python 2.5 (less than
by ken 18y ago
You're right that the features he mentioned seemed to not be terribly unique to Lisp.
But note that your claim wasn't really true before Python 2.5 (less than 2 years old). Imagine trying to write one of Emacs Lisp's most common special forms, save-excursion, in Python without context managers.
Even (especially!) Python programmers would admit that Python 2.5 is more powerful than Python 2.4. Emacs has a million lines of Lisp written with this feature not easily emulated in Python 2.4. The Lisp in my Emacs here uses save-excursion 9000 times; is there any Python program in the world that uses context managers 9000 times yet?
I'm impressed that a 20+-year-old language can hold its own with a 21st-century one under active development by somebody willing to (somewhat) break backwards compatibility. That's not to say that Elisp was this great 20 years ago -- it had, what, one kind of loop? -- but macros let it grow in directions that its users wanted. You can't really add editing-specific features with custom syntax to Python.
- jrockway 18y agosave-excursion could just be a function though. Here's what the implementation would look like. I don't know Python syntax, so I'll use Lisp, but I'll keep Python's featureset in mind. No macros, no lambdas. (defun save-excursion (function) (let ((point (point)) (mark (mark)) ...) (funcall 'function) (set-mark mark) (goto-char point))) Then you would say: (defun do-something nil (...)) (save-excursion 'do-something) Ideal, no. Possible, yes.
- jrockway 18y agoThat should be (funcall function). I shouldn't post code before I have coffee :)