Re:How to Write a Lisp Interpreter In Python (2010)
by ragnese on Friday August 02, 2019 @08:11AM
(#20592381)
The other things that "beginner" tutorials such as this do is they say "lisp" when they really mean "something resembling Scheme".
I started a project some time ago to write an elisp interpreter, mostly for fun. But since elisp is much more like Common Lisp than Scheme, it has a surprising amount more syntax than a Scheme does. The parser was much more complex than I initially thought it would be.
Re:How to Write a Lisp Interpreter In Python (2010)
by sansnomme on Friday August 02, 2019 @02:18AM
(#20590967)
You realize the person whose code you are criticizing wrote one of the classic books on Lisp right?
Re:How to Write a Lisp Interpreter In Python (2010)
by neilv on Friday August 02, 2019 @06:48AM
(#20591966)
I suspect he'd agree that this piece can be misinterpreted to give people the wrong idea about Scheme, despite the kind words he has for Scheme.
Scheme already has undeserved image problems, from various CS101 drive-by exposures that students get to it, never properly learning it.
Re:How to Write a Lisp Interpreter In Python (2010)
by nudq on Friday August 02, 2019 @02:58AM
(#20591107)
You realize that the OP's concerns actually intesify if the author in question is perceived as an authority on the topic, right?
Re:How to Write a Lisp Interpreter In Python (2010)
by iamnotacrook on Friday August 02, 2019 @04:21AM
(#20591400)
You realise it's problematic to emphasise typos, right?
Re:How to Write a Lisp Interpreter In Python (2010)
by nudq on Friday August 02, 2019 @05:33AM
(#20591673)
You realize it's problematic to emphasize typos, right?
(Thanks, would edit if I could.)
Re:How to Write a Lisp Interpreter In Python (2010)
by kerkeslager on Friday August 02, 2019 @01:26PM
(#20594794)
First, there's what I think is an important distinction of idiomatic programming in Scheme, for which the first example in the article gives the wrong idea, with a noble lie: that Java code implies an immediate return, but the Scheme code does not.
Were that Scheme expression not in a tail position of a procedure (which it probably wouldn't be), it wouldn't have effect analogous to that of the Java code. And a one-armed `if` makes little sense in a tail position in modern Scheme, and looks erroneous.
Scheme is a full imperative algorithmic language, and doesn't have to be used in a pure-functional way, but idiomatic programming in Scheme tends to lean towards functional when practical. You almost never do premature returns quite like that in Scheme, for example. (One can do most any memory-safe thing one wants, including the less-idiomatic and even the outrageously insane, but hopefully over time one learns the idiomatic ways, rather than overuses/misuses less-idiomatic features, like leaning on a crutch they don't need and that's actually harmful to them.)
Separate from that, another thing possibly misleading about this article is that their Scheme implementation doesn't do what's sometimes called "proper implementation of tail calls" (which would be required to be a real Scheme). Idiomatic Scheme will tend to use tail calls heavily, with impunity, which would not be the case if a Scheme implementation let such calls exhaust resources.