* partial instantiation of a new obj. : bug or feature ?
@ 1997-06-04 10:35 Christian Boos
0 siblings, 0 replies; only message in thread
From: Christian Boos @ 1997-06-04 10:35 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-06-04 17:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-04 10:35 partial instantiation of a new obj. : bug or feature ? Christian Boos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox