caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Associativity of new operators
@ 2006-01-20 16:06 Alessandro Baretta
  2006-01-20 16:13 ` [Caml-list] " William D. Neumann
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Alessandro Baretta @ 2006-01-20 16:06 UTC (permalink / raw)
  To: Ocaml

# let (++) = (-);;
val ( ++ ) : int -> int -> int = <fun>
# 10 ++ 4 ++ 6;;
- : int = 0
# let (@@) = (-);;
val ( @@ ) : int -> int -> int = <fun>
# 10 @@ 4 @@ 6;;
- : int = 12

The above toplevel session shows that the associativity of newly defined 
operators depends on the name of the operator itself. Is there a general rule to 
determine the associativity of the operator?

Alex



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Associativity of new operators
  2006-01-20 16:06 Associativity of new operators Alessandro Baretta
@ 2006-01-20 16:13 ` William D. Neumann
  2006-01-20 16:17 ` Julien Signoles
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: William D. Neumann @ 2006-01-20 16:13 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Ocaml

On Fri, 20 Jan 2006, Alessandro Baretta wrote:

> The above toplevel session shows that the associativity of newly defined 
> operators depends on the name of the operator itself. Is there a general rule 
> to determine the associativity of the operator?

I believe this is covered in section 6.7 of the manual.

William D. Neumann

---

"There's just so many extra children, we could just feed the
children to these tigers.  We don't need them, we're not doing 
anything with them.

Tigers are noble and sleek; children are loud and messy."

         -- Neko Case

Life is unfair.  Kill yourself or get over it.
 	-- Black Box Recorder


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Associativity of new operators
  2006-01-20 16:06 Associativity of new operators Alessandro Baretta
  2006-01-20 16:13 ` [Caml-list] " William D. Neumann
@ 2006-01-20 16:17 ` Julien Signoles
  2006-01-20 16:37   ` Alessandro Baretta
  2006-01-20 16:18 ` Eric Cooper
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Julien Signoles @ 2006-01-20 16:17 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Ocaml


> The above toplevel session shows that the associativity of newly defined
> operators depends on the name of the operator itself. Is there a general rule to
> determine the associativity of the operator?

Section 6.7 of the manual, there is a table giving the associativity of
the operators (and other constructions):

	http://caml.inria.fr/pub/docs/manual-ocaml/manual015.html


Hope this helps,
Julien
-- 
mailto:Julien.Signoles@lri.fr ; http://www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Associativity of new operators
  2006-01-20 16:06 Associativity of new operators Alessandro Baretta
  2006-01-20 16:13 ` [Caml-list] " William D. Neumann
  2006-01-20 16:17 ` Julien Signoles
@ 2006-01-20 16:18 ` Eric Cooper
  2006-01-20 16:18 ` David MENTRE
  2006-01-20 16:45 ` Richard Jones
  4 siblings, 0 replies; 7+ messages in thread
From: Eric Cooper @ 2006-01-20 16:18 UTC (permalink / raw)
  To: caml-list

On Fri, Jan 20, 2006 at 05:06:57PM +0100, Alessandro Baretta wrote:
> [...]
> The above toplevel session shows that the associativity of newly defined 
> operators depends on the name of the operator itself. Is there a general 
> rule to determine the associativity of the operator?

Section 6.7 of the manual. Basically, it's determined by the initial
character, so @^$ will have the same associativity as @.

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Associativity of new operators
  2006-01-20 16:06 Associativity of new operators Alessandro Baretta
                   ` (2 preceding siblings ...)
  2006-01-20 16:18 ` Eric Cooper
@ 2006-01-20 16:18 ` David MENTRE
  2006-01-20 16:45 ` Richard Jones
  4 siblings, 0 replies; 7+ messages in thread
From: David MENTRE @ 2006-01-20 16:18 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Ocaml

2006/1/20, Alessandro Baretta <a.baretta@barettadeit.com>:
> The above toplevel session shows that the associativity of newly defined
> operators depends on the name of the operator itself. Is there a general rule to
> determine the associativity of the operator?

Yep, the first letter of the operator determines its associativity.

See http://caml.inria.fr/pub/docs/manual-ocaml/manual015.html
"""
The table below shows the relative precedences and associativity of
operators and non-closed constructions. [...] For infix and prefix
symbols, we write "*..." to mean "any symbol starting with *".
"""

Best wishes,
d.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Associativity of new operators
  2006-01-20 16:17 ` Julien Signoles
@ 2006-01-20 16:37   ` Alessandro Baretta
  0 siblings, 0 replies; 7+ messages in thread
From: Alessandro Baretta @ 2006-01-20 16:37 UTC (permalink / raw)
  To: Ocaml

Julien Signoles wrote:
> 
> Section 6.7 of the manual, there is a table giving the associativity of
> the operators (and other constructions):
> 
> 	http://caml.inria.fr/pub/docs/manual-ocaml/manual015.html
> 
> 
> Hope this helps,
> Julien

Ah, I see. Although I Googled for "ocaml associativity" I missed that page, or 
probably I did not notic the table.

Thanks to everyone who answered. Also, please excuse me for posting such a 
trivial question.

Alex


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Associativity of new operators
  2006-01-20 16:06 Associativity of new operators Alessandro Baretta
                   ` (3 preceding siblings ...)
  2006-01-20 16:18 ` David MENTRE
@ 2006-01-20 16:45 ` Richard Jones
  4 siblings, 0 replies; 7+ messages in thread
From: Richard Jones @ 2006-01-20 16:45 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Ocaml

http://caml.inria.fr/pub/docs/manual-ocaml/manual015.html
http://sardes.inrialpes.fr/~aschmitt/cwn/2004.07.27.html#3

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-01-20 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-20 16:06 Associativity of new operators Alessandro Baretta
2006-01-20 16:13 ` [Caml-list] " William D. Neumann
2006-01-20 16:17 ` Julien Signoles
2006-01-20 16:37   ` Alessandro Baretta
2006-01-20 16:18 ` Eric Cooper
2006-01-20 16:18 ` David MENTRE
2006-01-20 16:45 ` Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).