Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!RRZ.Uni-Koeln.DE!news-koe1.dfn.de!main.Germany.EU.net!EU.net!howland.erols.net!ix.netcom.com!erkyrath
From: erkyrath@netcom.com (Andrew Plotkin)
Subject: Re: [INFORM] objectloop
Message-ID: <erkyrathE4LGBA.Jz2@netcom.com>
Organization: Netcom On-Line Services
X-Newsreader: TIN [version 1.2 PL2]
References: <m3ohedwakp.fsf@ue801di.lrz-muenchen.de>
Date: Sun, 26 Jan 1997 02:30:46 GMT
Lines: 46
Sender: erkyrath@netcom15.netcom.com

Florian Beck (fb@ue801di.lrz-muenchen.de) wrote:

> The trouble started when I tried to compile "Thief". It compiled
> fine, but when I tried to start it, I got a rune time error "No such
> property". 

> After I while I found out that

> [ NewRoom i;
>     for (i = selfobj + 1: i <= top_object: i++)
>         if (i has is_followable)
>             i.just_visited = 0;
> ];

> had to be changed to

> [ NewRoom i;
>     for (i = selfobj + 1: i <= top_object: i++)
>         if (i has is_followable &&(metaclass(i)==object))
>             i.just_visited = 0;
> ];

> Obviously classes now have "object" numbers between selfobj
> (i.e. player) and top_object. (They didn't when the thief example was
> written - Inform 5.5 presumably.)

> Now, why is this?

This sort of object loop -- a for loop over every object incrementally 
starting with "selfobj" -- was always an icky construction. In Inform 6, 
you should simply use

  objectloop (i) { ... }

Or, for your usage,

  objectloop (i has is_followable) { ... }

since you can put any condition in the parentheses.

--Z

-- 

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