Newsgroups: rec.arts.int-fiction
Path: news.duke.edu!newsgate.duke.edu!nntp-out.monmouth.com!newspeer.monmouth.com!howland.erols.net!portc.blue.aol.com.MISMATCH!portc03.blue.aol.com!uunet!dca.uu.net!ash.uu.net!world!buzzard
From: buzzard@world.std.com (Sean T Barrett)
Subject: Re: [Inform] Replaced routines and System_file
Message-ID: <GDuBs2.IBs@world.std.com>
Date: Thu, 24 May 2001 12:52:50 GMT
References: <GDsH2v.925@world.std.com> <20010523153131.23346.00001199@ng-cd1.aol.com>
Organization: The World Public Access UNIX, Brookline, MA
Lines: 49
Xref: news.duke.edu rec.arts.int-fiction:87476

OKB -- not okblacke <brenbarn@aol.comRemove> wrote:
>>You seem to be saying that that it's not possible to make a library
>>mod which both replaces a library function and is itself replaceable.
>
>Well, I was saying that, sort of, and I'd be glad if I was wrong.  What I
>was saying was that it's not possible to make a library which Replaces a
>standard library routine and allows the replacement routine to be replaced.
>Is this possible?

Right, that's what I meant but didn't say. It's possible, but...
well, see below.

>Another beef I had with System_file/Replace is that the Replace directive
>must come BEFORE the instance you want to Replace.  So if your library is
>included after Parser, but needs to Replace a routine provided in Parser,
>you're forced to break the library into two files (or just make the programmer
>put in Replace line all by itself at the head of the source code).

I agree that this situation with "replace" is rather clumsy design.
So I looked up to see what I had done. It turns out that it is indeed
possible for a library to get around both of these problems with a
single technique, but, unfortunately, it is basically only possible
for an author to use one such library at a time, so the technique
cannot be recommended in practice.

The trick is to make the library include parser:

 mylib.h:
   ! note, never define system_file in this file
   Replace SomeFunc;
   Include "Parser";
   [ SomeFunc; "How now brown cow."; ];
   ! games can now replace SomeFunc

and then have the game include "mylib" *instead* of "parser". I have
no idea why this combination of 'replace' and definition works; as I
mentioned before, it is inconsistent with the semantics specified
for "system_file" in DM3.

One could even write another library in the same way if it
depends on this library, by having it include "mylib" and
having the game include the new one.

But in general people shouldn't release library mods this way,
since any two independent mods of this form would not be
compatible with each other. Doing it for personal use is
fine though.

SeanB
