Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] about Obj.magic
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] about Obj.magic
Pierre Weis wrote:

>>An 'almost legal' use of Obj.magic is to populate an array with dummy 
>>For example:
>>    class Deep  ..
>>    let a = Array.make 100  (Obj.magic 0 :> Deep) in
>>    let len_a = ref 0 in
>>This is roughly as safe as an unsafe array access,
>>only now the array length is a variable.
>>John Max Skaller,
>>snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
>I'm afraid that this use is not ``almost legal'' and, on the contrary,
>it is strongly discouraged by good programming practice!
And I'm sorry too, because it is the only way to achieve the desired effect:
Ocaml could do well with a variable length array in the standard 
library, IMHO.

John Max Skaller,
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: