3 ms·
Classes definitely make sense for some things, especially those that don't have a Python analogue, such as symbols. What do you gain by wrapping a native repre
by Straw 5y ago
Classes definitely make sense for some things, especially those that don't have a Python analogue, such as symbols.
What do you gain by wrapping a native representation of the same thing with a class? A cons cell _is_ a 2 element tuple.
That was only one example, in general your Python example has a somewhat Javaish, imperative style. I think it could also probably benefit from using the string libraries a little more.
As another commenter noted, Norvig did a similar thing in Python, and its ~100 lines, you might take a look for inspiration:
http://norvig.com/lispy.html http://norvig.com/lispy.html
However note that he goes even further and embeds Scheme lists as Python lists, which have different performance properties.
- eatonphil 5y ago> I think it could also probably benefit from using the string libraries a little more. Definitely agree. I forgot about some builtins like str.isdigit(), str.isalpha(). But Java also has Character.isDigit and Go has unicode.IsLetter and so forth. I was just using the methods that came immediately to mind and in some cases did miss builtins in all implementations.