3 ms·
Yes. A function is an object just like any other. What more do you need? If you say macros, I'd argue that's not quite the same as "functional".
by xapata 9y ago
Yes. A function is an object just like any other. What more do you need?
If you say macros, I'd argue that's not quite the same as "functional".
- Waterluvian 9y agoLots of easy handling of structures immutably. Which Python has a good bit of for sure, with comprehension especially. But I could use more. :) I wish everything immutablejs gave me was built in to Python. :)
- xapata 9y agoComparing with immutablejs, there are 4 broad categories that match: lists, dicts, sets, and iterators. Tuple slicing and concatenation gives you the "immutable" behavior for ordered data. For sets and dicts, one could create a subclass that override add/insert/set methods to return a modified copy. Iterators already have excellent support. I'm not an immutablejs user, but my first skim of the docs doesn't make it clear what's missing from Python. If the immutable subclasses would be valuable, I'll gladly make a module for it. There's already frozenset. A frozendict didn't seem as useful (according to core devs).
- xapata 9y agoPlus, I forgot that sets have nice operators for union, intersection, etc. So you don't need to override anything there.
- inexplicably 9y agoSane name spaces, no hacks like "nonlocal", immutable bindings by default, more fluid syntax, functors, encapsulation, tail call elimination.
- xapata 9y agoYou're using terms like "sane" and "hacks" that have negative connotations without acknowledging the benefit those design decisions provided over the history of the language. Language design involves trade-offs. For example, tail call elimination would obfuscate tracebacks and make the interpreter more complex. Need is different than want. You might want tail call elimination, but you don't need it to write elegant functional style code.
- shakna 9y ago> What more do you need? Tail call elimination, so you don't have the tiny recursion that Python locks you too. Real lambdas instead of the arbitrarily limited one's Python has.