From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id GAA09220; Sat, 27 Apr 2002 06:11:29 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id GAA09064 for ; Sat, 27 Apr 2002 06:11:28 +0200 (MET DST) Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.25.148.40]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g3R4BQT15725 for ; Sat, 27 Apr 2002 06:11:27 +0200 (MET DST) Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id g3R4BPXt024104; Sat, 27 Apr 2002 14:11:25 +1000 (EST) Received: from ozemail.com.au (ppp7.dyn146.pacific.net.au [210.23.146.7]) by wisma.pacific.net.au with ESMTP id OAA20324; Sat, 27 Apr 2002 14:11:23 +1000 (EST) Message-ID: <3CCA24EB.5040805@ozemail.com.au> Date: Sat, 27 Apr 2002 14:11:23 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: Jerome Vouillon CC: caml-list@inria.fr Subject: Re: [Caml-list] How to compare recursive types? Solution! References: <3CBD4523.6080707@ozemail.com.au> <87y9fmr4fo.dlv@wanadoo.fr> <3CC656E1.5020108@ozemail.com.au> <3CC675D7.40ADAD0F@ps.uni-sb.de> <3CC6AF9F.5040801@ozemail.com.au> <3CC6C986.A32F40F7@ps.uni-sb.de> <3CC757B2.7030706@ozemail.com.au> <3CC78908.7050507@ozemail.com.au> <3CC7AA30.4080700@ozemail.com.au> <20020425133123.GB4702@strontium.pps.jussieu.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jerome Vouillon wrote: > >Assume the following definition: > typedef y = int * y; >Then "y" and "int * y" are not equal according to your algorithm. >Is it what you expect? > It's what I expect from the algorithm, yes: the interpretation would be a pair whose first component contains a y which will be cyclic .. however none of the pointers in that cycle point to the top level pair. Its a dubious distinction though .. clearly I need to know that int * y is a subtype of y .. > >Why don't you make the pointers explicit in the type? > The language does have pointers. I could ban type recursion that does not go through a pointer, and that would make sense (it is what C does). However, I allow unions like: union list = Empty | Cons of int * list where you can just write "list" instead of having to specify a pointer .. part of the reason is that the underlying implementation always uses a pointer for constructor arguments, a single C type struct { int variant; void *data; } is used for variant components. Now I am trying to generalise that, to get rid of what might appear as an inconsistency .. direct recursion is allowed in one place but not another. >Then, the two >types definitions below would not define the same type > typedef x = ref(x) * int; > typedef y = (ref(y) * int) * int; >while these two would define the same type > typedef x = ref(x) * int; > typedef y = ref(ref(y) * int) * int; > Yes .. but what would I do for the list? To make matters worse, my pointers always allow writing .. i'd have to adopt a second kind that didn't like 'ref' .. the experience in C/C++ with 'const' suggests it might be worth trying to avoid this . . so I'm trying to use the approach languages like ocaml use where the use of pointers is hidden .. at the same time, I support overloading, and expand types in structs (products) to reduce the cost of dereferencing and garbage collection. Perhaps what I am trying to do is impossible. -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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