From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,dbbbb21ed7f581b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!j19g2000yqk.googlegroups.com!not-for-mail From: xorque Newsgroups: comp.lang.ada Subject: Re: Operation can be dispatching in only one type Date: Sat, 21 Nov 2009 21:45:52 -0800 (PST) Organization: http://groups.google.com Message-ID: <53a35ed9-88ac-43dc-b2a2-8d6880802328@j19g2000yqk.googlegroups.com> References: <025105f2-5571-400e-a66f-ef1c3dc9ef32@g27g2000yqn.googlegroups.com> <94e76749-c49c-45aa-b7dc-386da0d71c66@e4g2000prn.googlegroups.com> <1u0im1tdws15u.1n9v9rz7bu4t4$.dlg@40tude.net> <39kf90ha60px$.d7746cf5cx6h.dlg@40tude.net> <691d6892-bc5e-4d81-8025-c36556bf2593@13g2000prl.googlegroups.com> <1h9hilcg5i6il.12edpgu4szw1h.dlg@40tude.net> <1wtsriaxu0s4s$.ikwnnz5teukp$.dlg@40tude.net> <1iipp3bn16fe2.yqa1gz1ru17a$.dlg@40tude.net> <18wh86jvjvoe0.cofxcc8udm6q$.dlg@40tude.net> NNTP-Posting-Host: 78.143.202.207 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1258868752 2017 127.0.0.1 (22 Nov 2009 05:45:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 22 Nov 2009 05:45:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j19g2000yqk.googlegroups.com; posting-host=78.143.202.207; posting-account=D9GNUgoAAAAmg7CCIh9FhKHNAJmHypsp User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.0.13) Gecko/2009081019 Firefox/3.0.13,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8190 Date: 2009-11-21T21:45:52-08:00 List-Id: I have to say I'm quite impressed that my question started so much discussion. For this (minor) project, I tried a multitude of different approaches and ended up with one that appeared safe, right until it ended up causing GNAT to have some sort of heart attack: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42140 After some five or six attempts with different methods, I think I'm at the point where I've given up on the idea of using more than one tagged type for this and will likely just expose opaque integer identifiers. The problem was really one of state rather than dispatching, for me. I wanted one 'archiver' type to dispatch operations that were stateless ("Can this archiver open this archive?"), one type to hold per-archive state (the state of an open archive) and one type to hold per-file state (a Stream_IO.File_Type handle or an offset into an open zip file). I believe I sketched an example of the kind of interface I wanted (in more or less completely invalid Ada-ish pseudocode): Archive : access Archiver.Archive_t'Class; File : access Archiver.File_t'Class; for Index in Archivers'Range loop if Archiver.Can_Mount (Archiver => Archivers (Index), Path => "file.zip") then Archive := Archiver.Open_Archive (Archiver => Archivers (Index), Path => "file.zip"); File := Archiver.Open (Archive => Archive, Path => "/directory/file.txt"); Archiver.Close (File); Archiver.Close_Archive (Archive); end if; end loop; This interface would have been entirely internal as somebody actually using the code would have used it through another layer (removing the requirement to test against different archivers and in effect making it impossible to tell that there are even multiple packages involved). To the poster that didn't know what PhysicsFS was: http://icculus.org/physfs/ A small example of how the interface is used (note that the fact that there are multiple archivers involved is completely hidden): http://icculus.org/physfs/physfstut.txt Regards, xw