Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Christian Boos <boos@arthur.u-strasbg.fr>
To: caml-list@inria.fr
Subject: partial instantiation of a new obj. : bug or feature ?
Date: Wed, 4 Jun 1997 12:35:41 +0200	[thread overview]
Message-ID: <199706041035.MAA15000@arthur.u-strasbg.fr> (raw)


Hi, 

It seems that partial instantiation of objects' new statement didn't work 
as I expected.
I thought that the creation of an object takes place when all the arguments
are available.

The following example illustrates this:

  # class test (a : int) (b : int) =
       val a = a
       val b = b
       method get = (a, b)
    end;;
  class test (int) (int) = val a : int val b : int method get : int * int end
  # let a1 = new test 1;;
  val a1 : int -> test = <fun>
  # let b1 = a1 1;;
  val b1 : test = <obj>
  # let b2 = a1 2;;
  val b2 : test = <obj>
  # b1 = b2;;
  - : bool = true
  # b1#get;;
  - : int * int = 1, 2
  # b2#get;;
  - : int * int = 1, 2
  # 

This forces one to write things like :

  let objs = Array.map (fun i -> new test 1 i) vals

instead of the more intuitive :

  let objs = Array.map (new test 1) vals


Maybe someone wants to comment ?

-- Christian





                 reply	other threads:[~1997-06-04 17:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=199706041035.MAA15000@arthur.u-strasbg.fr \
    --to=boos@arthur.u-strasbg.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