Browse thread
partial instantiation of a new obj. : bug or feature ?
- Christian Boos
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Christian Boos <boos@a...> |
| 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