Am 05.10.2012 16:42, schrieb Aaron Meurer:
I have to disagree, and believe me, I'm the last person to prefer an OO
style over an imperative one when imperative would do just fine (this is
one of the reasons that I hate Java).
Continuing on OT-ness:
In Java, you can always write static functions and use classes as if
they were namespaces.
I don't like Java because it's incredibly verbose, just for the purpose
of making the life of the compiler minimally easier.
But enough OT here.
> You run into problems with a functional
interface in Python real fast because there are no attributes, and it's
impossible to inspect the code of the function.
Huh? what?
Inspecting the code of a function isn't even remotely relevant to any
functional programming style.
Typical functional style uses structs (dictionaries with fixed sets of
keys, if you will) and opaque function objects, the latter being
combined using partial application of expressions to parameters.
This idiom doesn't work well in Python because the syntactic overhead is
a bit too high.
But the semantics is all there: you can do structs via classes
containing just data, and partial application via lambdas.
So you'll end up creating
functions that return dictionaries of the data you want. When that happens,
you are better off just using a class, which is a much cleaner way to have
a namespace (and you also get inheritance for free!).
You don't *want* inheritance if you have a good higher-order function
infrastructure, believe me :-)
I'm not sure that such an infrastructure can be done in Python.
It's certainly not there in SymPy, right here, right now.
However, the differences are gradual anyway, particularly since Python
is doing everything (including the inheritance and call machinery) using
duck typing.
A function is an object of the Callable class. A class is a struct
(dictionary) that contains data and functions. You can do everything
that either idiom, functional or OO, allows.
I'd recommend concentrating less on functional-vs-OO and more on "what
interface do we need for each task".
Just my 2c :-)
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.