English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] infix precedence
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-28 (18:01)
From: John Prevost <j.prevost@c...>
Subject: Re: [Caml-list] infix precedence
>>>>> "zd" == dengping zhu <zhudp@cs.bu.edu> writes:

    zd> I want to convert these code into ocaml. How can find so many
    zd> different 'first characters'? Because the available characters
    zd> in ocaml are:

    zd> **...  right *... /... %...  left +... -...  left @... ^...
    zd> right

    zd> Do you have any sugestion?

Take a look at section 6.7 of the manual for precedence rules, and
section 6.1 (under the heading "Prefix and infix symbols") for the
list of symbols.  In short, this is the list of all the available
infix symbols, in order of precedence:

!... ?... ~...                          prefix
**...                                   right
*... /... %...                          left
+... -...                               left
@... ^...                               right
=... <... >... |... &... $... %...      left

This means that you might have some trouble with your infix levels,
but there are normally ways to organize things for what you'd like.  I
find, also, that having just a few levels and using parenthesis for
the rest of the time can work quite well.  As you note, using this
style for everything can be painful, but having infixes for only a few
specific things can help immensely.


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners