77 points · by czheo · 9y ago · 21 comments
f(x) = x^2 + 1
But most of the other ideas are less intuitive than their native counterparts. For example, I think that the native form: 3 in [1,2,3,4,5]
is clearer than: [1,2,3,4,5] /contains/ 3Also, declaring types for the function and arguments (which is optional but has been strongly recommended since the Fortran '77 era) had to be done outside of the function, which again is unlike the usual syntax.
The only code I've ever seen statement functions used in dated from the 1970s.
Might be fun to show pythonic equivalents for the ones that are relatively easy to make pythonic. You might discover some useful pythonic functions along the way.
An example of syntactic sugar is list comprehensions. It's a new syntax for expressions using map, filter, etc. It's "new" syntax for something that can be described in terms of the "old" syntax without altering the semantics.
Given the name, I was expecting some kind of macro system or hacks to the Python parser.
What it severely lacks is readme that clearly states what it does with some realistic examples and is understandable by people who have no idea what CLOS is, so: It allows you to do function overloading which is resolved dynamically based on actual types of passed values or even values themselves. With the included (trivial) C extension it's only about 50% slower than Python method call, so in all for expected usecase it's faster than Visitor pattern not to mention more DRY.