News for hackers. Stuff that matters.
Re:Coconut – Pythonic functional programming language by hcarvalhoalves on Thursday June 23, 2016 @12:14PM (#11962124)
This is cool, but you can go pretty far w/ FP idioms in Python without requiring a DSL/transpiler:

- Toolz (http://toolz.readthedocs.io/en/latest/) provides the same primitives from Clojure (including partial functions, compose, juxt, etc)

- Pysistence (https://pypi.python.org/pypi/pysistence/) provides immutable data structs

- For parallel map you can use https://pypi.python.org/pypi/python-pmap/1.0.2

- TCO is achievable w/ a decorator regardless of AST manipulation (like Clojure's `loop/recur` construct)

The only thing left is pattern matching and more powerful destructuring (Python already has limited support for it), I guess.

Re:Coconut – Pythonic functional programming language by fiatjaf on Thursday June 23, 2016 @02:40PM (#11963388)
No, you can't, because lambdas.
Re:Coconut – Pythonic functional programming language by quietwhisper on Thursday June 23, 2016 @05:29PM (#11964449)
I know (and bemoan) that lambdas can only have a single expression returned, but can't you just use a named function? (Not as nice, I agree, but doesn't put a hard limit on FP in python.)
Re:Coconut – Pythonic functional programming language by kd0amg on Thursday June 23, 2016 @05:31PM (#11964457)
And manually closure-convert everything too?
Re:Coconut – Pythonic functional programming language by devishard on Thursday June 23, 2016 @06:16PM (#11964702)
Python supports nested functions, so closure conversion isn't necessary.
Re:Coconut – Pythonic functional programming language by Lambdanaut on Thursday June 23, 2016 @05:10PM (#11964328)
Could you elaborate on that?
Re:Coconut – Pythonic functional programming language by SwellJoe on Thursday June 23, 2016 @05:51PM (#11964560)
Python lambda is somewhat limited, compared to lambda in some other languages. Guido isn't overly fond of lambda or other functional building blocks (and even planned to remove it from Python, before there was a sufficient outpouring of support for keeping it). http://www.artima.com/weblogs/viewpost.jsp?thread=98196

As I understand it, the primary limitation is that Python lambda only works with a single expression (I think it also has some weirdness regarding scope when calling functions?). I haven't poked seriously at Python since around about the time they were talking about removing it, so I probably have no idea what I'm talking about.

The idea is that generators and list comprehensions do the things most people do with lambdas in a more Pythonic way.

Re:Coconut – Pythonic functional programming language by fovc on Thursday June 23, 2016 @09:05PM (#11965512)
I think the scoping issues you're referring to were resolved a while ago (PEP 227) -- nowadays lambda scope rules are the same as named functions.
Re:Coconut – Pythonic functional programming language by merlincorey on Thursday June 23, 2016 @05:29PM (#11964447)
Python lambdas are explicitly artificially limited to a single expression. Python has statements which are not expressions, mostly control statements and looping constructs.
Re:Coconut – Pythonic functional programming language by fovc on Thursday June 23, 2016 @09:06PM (#11965517)
The syntax isn't the greatest, but you can get pretty far with Python's ternary expression. Generators in my experience remove the need for most loops. Where lambdas feel really subpar for me is the lack of 'let' and error-handling.
Re:Coconut – Pythonic functional programming language by Phrodo_00 on Thursday June 23, 2016 @09:22PM (#11965594)
While it IS a conscious decision to force lambdas to be a single expression, extending it to be able to be multiline would screw up with indentation being irrelevant inside of a function call too.
Re:Coconut – Pythonic functional programming language by coconutlang on Thursday June 23, 2016 @09:19PM (#11965578)
> The only thing left is pattern matching and more powerful destructuring (Python already has limited support for it), I guess.

Coconut does both of those!

Re:Coconut – Pythonic functional programming language by _navaneethan on Thursday June 23, 2016 @12:53PM (#11962462)
Pattern matching

Is it mimics the Erlang behaviour?

Re:Coconut – Pythonic functional programming language by spraak on Thursday June 23, 2016 @07:38PM (#11965111)
Reminds me a lot of Elixir actually. I'd really prefer a purely functional language with LISP syntax. Does anyone know of any? I find it easier to understand than Haskell..
Re:Coconut – Pythonic functional programming language by fiddlerwoaroof on Thursday June 23, 2016 @10:25PM (#11965817)
There's also Shen: http://shenlanguage.org/
Re:Coconut – Pythonic functional programming language by benley on Thursday June 23, 2016 @09:22PM (#11965599)
Is Clojure close enough? Or perhaps LFE (Lisp-flavored Erlang)?