partial instantiation of a new obj. : bug or feature ?

From: Christian Boos (boos@arthur.u-strasbg.fr)
Date: Wed Jun 04 1997 - 12:35:41 MET DST


Date: Wed, 4 Jun 1997 12:35:41 +0200
Message-Id: <199706041035.MAA15000@arthur.u-strasbg.fr>
From: Christian Boos <boos@arthur.u-strasbg.fr>
To: caml-list@inria.fr
Subject: partial instantiation of a new obj. : bug or feature ?

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



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:11 MET