Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Object Attribute Accessor Syntax Extension
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Object Attribute Accessor Syntax Extension
From: Alex Baretta <>
> Jacques Garrigue wrote:
> > It may also be nice to have another small extension, so that
> >         o#f <- expr
> > would be handled as
> >         o#set_f <- (expr)
> Doesn't this look dangerously similar to C++? Let us not turn to the 
> Dark Side of object orientation...

I just took the syntax from ruby.
Note that both in ocaml and ruby, you cannot access directly object
fields, so the above syntax is not ambiguous: it can only be syntactic
sugar for a method call.
This is not to be mixed with overloading of assignment in C++, which
changes the semantics of an existing operator.

Jacques Garrigue