Am 26.02.2014 00:02, schrieb Sergey Kirpichev:
On Tuesday, February 25, 2014 8:31:02 PM UTC+4, Aaron Meurer wrote:
Really bad idea.
What's bad about it?
> It's better to have an ability to define arbitrary
infix operator
In general, yes, but you definitely need to weigh it against several issues:
- Dealing with fixity, i.e. infix, prefix, postfix. We'd want all three
if we're to stick closely to mathematical notation.
- How much parenthesizing do you want? If you wish to allow prefix and
postfix operators at the same precedence level, things can get
ambiguous: if % is both prefix or postfix, % x % could be either
(% x) % or % (x %). This might be undesirable if the language has no
preexisting rule of that kind (ever additional rule means a steeper
learning curve).
- How do you distinguish between operators and functions?
- How do you keep precedence levels under control? In particular, how do
you make sure that programmers know what precedence levels apply if they
read code that makes heavy use of user-defined operators?
> (like Haskell, for example).
In Haskell, every function is a prefix operator (despite appearances,
there is no such thing as a multi-parameter function).
This simplifies syntax tremendously (semantics, too, but that's
irrelevant here), which means that arbitrary operators fit in easily.
Unfortunately, this isn't necessarily easy in other languages.
Given all these constraints and caveats, I find it hard to judge any
proposal as good idea or bad idea. You always have to look at the design
goals (which may or may not match SymPy's), and at the existing language.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/530DE49F.2020303%40durchholz.org.
For more options, visit https://groups.google.com/groups/opt_out.