English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2002-06-02 (15:16)
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, mailto:skaller@ozemail.com.au
>>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, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners