Article View: comp.lang.misc
Article #7022Re: Metalanguages in environments where code is data.
From: Peter da Silva
Date: Thu, 10 Nov 1994 18:58
Date: Thu, 10 Nov 1994 18:58
65 lines
2822 bytes
2822 bytes
In article <1994Nov9.194316.14800@netlabs.com>,
Larry Wall <lwall@netlabs.com> wrote:
> You can do it almost exactly the same in Perl, except there's no
> need to "eval" the final argument to "rule".
> use Make;
> $CFLAGS = "-O -g";
> $OBJS = "main.o frob.o";
> $LIBS = "-lreadline";
> rule "frob", $OBJS, sub {
> system "$CC $CFLAGS $OBJS -o frob $LIBS";
> };
> make;
OK, point to perl. How would you manipulate something like:
event_wait {
{control $door close} {
signal $alarm "Door $door closed"
}
{control $door open} {
signal $alarm "Door $door opened"
}
}
Easy enough, but now you want to add user-defined events to the end of
this structure:
set default_event_list {
{control $door close} {
signal $alarm "Door $door closed"
}
{control $door open} {
signal $alarm "Door $door opened"
}
}
set event_list $default_event_list
Then later
lappend event_list {
{control $door open} {
set last_event [list $door opened]
}
}
event_wait $event_list
Sometimes it's convenient to add stuff at random times, even
algorithmically, within a consistent syntax.
I will readily admit that this example could probably be done other ways,
such as creating a word to build an event table and assembling it by hand.
I'm just curious how Perl would resolve the above example.
> runoff qq{
^^--- could you explain this?
--
Peter da Silva `-_-'
Network Management Technology Incorporated 'U`
1601 Industrial Blvd. Sugar Land, TX 77478 USA
+1 713 274 5180 "Hast Du heute schon Deinen Wolf umarmt?"
Technical Details
Message-ID:
<id.57ME1.GJ5@nmti.com>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!swrinde!news.uh.edu!uuneo.neosoft.com!nmtigw!peterReferences:
<id.IWEE1.A3H@nmti.com> <39bo03$d4e@csnews.cs.colorado.edu> <id.QQFE1.XIE@nmti.com> <1994Nov9.194316.14800@netlabs.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,9bda08f2f068881f X-Google-Attributes: gidf891f,public X-Google-Thread: 10259a,9bda08f2f068881f X-Google-Attributes: gid10259a,public X-Google-Thread: 103d24,9bda08f2f068881f X-Google-Attributes: gid103d24,public X-Google-Thread: 10eb76,9bda08f2f068881f X-Google-Attributes: gid10eb76,public X-Google-Thread: 1025b4,9bda08f2f068881f X-Google-Attributes: gid1025b4,public X-Google-ArrivalTime: 1994-11-10 19:15:00 PST Newsgroups: comp.lang.misc,gnu.misc.discuss,comp.lang.scheme,comp.lang.tcl,comp.lang.perl Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!swrinde!news.uh.edu!uuneo.neosoft.com!nmtigw!peter From: peter@nmti.com (Peter da Silva) Subject: Re: Metalanguages in environments where code is data. Message-ID: <id.57ME1.GJ5@nmti.com> Sender: peter@nmti.com (peter da silva) Organization: Network/development platform support, NMTI References: <id.IWEE1.A3H@nmti.com> <39bo03$d4e@csnews.cs.colorado.edu> <id.QQFE1.XIE@nmti.com> <1994Nov9.194316.14800@netlabs.com> Date: Thu, 10 Nov 1994 18:58:48 GMT Lines: 65