caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Sebastien Ferre <ferre@irisa.fr>
To: caml-list@inria.fr
Cc: "Sébastien Ferre" <ferre@irisa.fr>
Subject: syntax changes from 3.08 to 3.10
Date: Wed, 11 Jul 2007 12:10:10 +0200	[thread overview]
Message-ID: <4694AC82.2060001@irisa.fr> (raw)

Hi,

moving my application from OCaml 3.08 to 3.10,
I encountered 2 syntax problems, i.e. syntax errors
when compiling:

1. record copy and modification:

   {f x with y = 1; z = 2}

this can be solved by parenthesizing the
evaluation of the record to be copied.

   {(f x) with y = 1; z = 2}

2. object copy and modification in a method:

   {< x = 1; y = 2>}

   OCaml says the first field is a bool instead of an int,
   which leads me to think it parenthesizes in the following way:

   {< x = (1; y = 2)>}

   In fact, this behaviour is only when compiling with camlp4o:

   ocamlc -pp ocamlp4o ...

   The work-around I found to implement a copy method is as follows:

   class c =
     object (self)
       val x = 0
       val y = 0

       method copy = (Oo.copy self) # copy_aux
       method private copy_aux = x <- 1; y <- 2; self
     end


Has anybody encountered the same problem ? Is there a better workaround 
? Is it a bug ?

Sébastien


             reply	other threads:[~2007-07-11 10:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-11 10:10 Sebastien Ferre [this message]
2007-07-11 11:28 ` [Caml-list] " Nicolas Pouillard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4694AC82.2060001@irisa.fr \
    --to=ferre@irisa.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).