* Re[2]: [Caml-list] Custom operators in the revised syntax
@ 2007-05-14 8:45 dmitry grebeniuk
0 siblings, 0 replies; only message in thread
From: dmitry grebeniuk @ 2007-05-14 8:45 UTC (permalink / raw)
To: Nicolas Pouillard
Hello, Nicolas.
>> > Something general like: x `foo` y ?
>> Exactly.
NP> I've a tiny patch to do that:
NP> 2 ``List.mem`` [1;2;3]
Sometimes it is very convenient (``map`` and function
compositions are good examples). But I prefer syntax
where one thing should be done in one way (that's why
I prefer revised syntax -- lesser ambiguities than in
original syntax). And the principle "there is more than
one way to do it" is good for "weak" languages such as
perl and bash and not for "strict" languages of ML family.
I agree that "bad programmer will write unreadable code
in any language/syntax", but it's better not to give
to programmer any choices when it there is no need --
when the choice does not affect the result (for example,
usually people don't need to think about whether they
should write "fun .. -> .." or "function .. -> ..").
And one more "against" point: using infix notation for
functions allows to write "ad hoc"-code, which can grow
enormously. In the original version of code there can be
only "arg1 ``myfunc`` arg2", but it can grow to
"(some complex expression1) ``some other things`` (some
other expression)" over several lines. It can be compared
to perl's "post-conditions":
"<do_something> if <condition>".
And, again, precedence and associativity: some people
will want "a ``b`` c ``d`` e" to work as
"(a ``b`` c) ``d`` e", some people -- as
"a ``b`` (c ``d`` e)", and which interpretation is correct?
The result of "1 ``(fun x y -> 2*x + 3*y)`` 2 + 3" will be
1*2+2*3+3 or 1*2+3*(2+3)? And every programmer must keep
these things in the head to write and understand caml code.
However, do anything you want, but please don't turn ocaml
into perl, or, omg, haskell.
--
WBR,
dmitry mailto:gds-mlsts@moldavcable.com
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-05-14 8:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-14 8:45 Re[2]: [Caml-list] Custom operators in the revised syntax dmitry grebeniuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox