Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!news.ruhr-uni-bochum.de!news.uni-stuttgart.de!news.belwue.de!swidir.switch.ch!news.grnet.gr!btnet-feed2!btnet!tank.news.pipex.net!pipex!www.nntp.primenet.com!nntp.primenet.com!netcom.com!erkyrath
From: erkyrath@netcom.com (Andrew Plotkin)
Subject: Re: [Inform] Attribute-query on strings?
Message-ID: <erkyrathE202wK.EKH@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <586p57$7aa@curofix.ida.liu.se>
Date: Fri, 6 Dec 1996 16:24:20 GMT
Lines: 32
Sender: erkyrath@netcom.netcom.com

FReDRiK RaMSBeRG (WILdcARD) (d91frera@ida.liu.se) wrote:
> I have found a difference between the way Jzip and Frotz interpret Z-code.
> I wrote a routine that checked if an object had the door-attribute set. 
> Sometimes the object was a string. Jzip simply returned false, which I 
> personally prefer. A string is an object that can't have properties or
> attributes, right? Frotz, on the other hand, stopped with the message 
> "Illegal object number".

Frotz is right; Jzip is wrong. Your program is doing something which is 
illegal on the Z-machine.

The "x has attribute" condition is compiled to a Z-machine opcode which is
only valid for valid objects.  When x is a string's packed address, Jzip
is almost certainly reading a random bit of memory -- which may be "true"
or even crash at unpredictable times. Stay away. 

> With Inform claiming to be a pretty fully
> object oriented language, shouldn't it be allowed to query a string for
> attributes?

Maybe so, but it currently doesn't. If it does in the future, it will do
it by compiling a longer sequence of opcodes -- essentially "x isclass
Object && x has attribute" -- which never executes an invalid Z-machine 
opcode. *That* would behave correctly on all interpreters.

--Z


-- 

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
borogoves..."
