Newsgroups: rec.arts.int-fiction
From: Suzanne Britton <tril@igs.net>
Subject: Re: [Tads] Pointers and assignments
References: <HbrD7.385171$j65.99471844@news4.rdc1.on.home.com>
Message-ID: <slrn9tsio3.1ns.tril@miranda.igs.net>
User-Agent: slrn/0.9.7.2 (Linux)
NNTP-Posting-Host: 216.58.91.172
Date: 30 Oct 2001 00:27:52 -0600
X-Trace: corp.newsgroups.com 1004423272 216.58.91.172 (30 Oct 2001 00:27:52 -0600)
Lines: 65
X-Comments: This message was posted through Newsfeeds.com
X-Comments2: IMPORTANT: Newsfeeds.com does not condone, nor support,  spam or any illegal or copyrighted postings.
X-Comments3: IMPORTANT: Under NO circumstances will postings containing illegal or copyrighted material through this service be tolerated!!
X-Report: Please report illegal or inappropriate use to <abuse@newsfeeds.com>
X-Abuse-Info: Please be sure to forward a copy of ALL headers, INCLUDING the body (DO NOT SEND ATTACHMENTS)
Organization: Newsfeeds.com http://www.newsfeeds.com 80,000+ UNCENSORED Newsgroups.
Path: news.duke.edu!newsgate.duke.edu!nntp-out.monmouth.com!newspeer.monmouth.com!nntp.abs.net!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!corp.newsgroups.com
Xref: news.duke.edu rec.arts.int-fiction:94087

In article <HbrD7.385171$j65.99471844@news4.rdc1.on.home.com>, Mercury wrote:

> The trick here is finding out which property in the actor to refer
> to for the assignment. How do I do that?

Use property pointers. Here's how I would implement your example:

modify Me
    orange=0
    yellow=0
    green=0
    red=0
;

class ball: item
    color = nil       // Color string description, must define
    color_ptr = nil   // Color property pointer, must define

    doBounce(actor) = {
        "You bounce the <<self.color>> ball for a while. ";
        actor.(self.color_ptr) += 2;
        if (actor.(self.color_ptr) > 4)
            "You are getting sick of bouncing this color ball and have the
            urge to bounce another color. ";
    }
;

orangeball: ball
    color="orange"
    color_ptr = &orange
;
yellowball: ball
    color="yellow"
    color_ptr = &yellow
;
greenball: ball
    color="green"
    color_ptr = &green
;
redball: ball
    color="red"
    color_ptr = &red
;

Property pointers are a little strange. As I understand, they don't
refer to any particular object until you use them--just a generic
property on any object. Thus a pointer is defined and used like this:

    local ptr = &foo;
    obj.(ptr);          // call method foo on obj
    anotherobj.(ptr);   // call method foo on anotherobj

Suzanne

--
tril@igs.net - http://www.igs.net/~tril/
"I'm aware of that, sweetheart. It's just that when I wake up to a hissing
goat skull on my nightstand, and it hops off and runs across the floor on
spider legs, I sleep a lot better knowing where it ran off to."
                                                          - Ted (Red Meat)


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
