R
Rich Morin
Ruby Graph Language (RGL) allows graphical structures
to be modeled as collections of objects. So, you can
ask a node to iterate through its neighbors, etc.
I've been toying with ways to extend this notion, using
(say) method_missing. Here's a hand-waving example,
where "you" are assumed to be a Ruby object:
Let's say that I want to find out how many of your
neighbors have cats. Although you don't know the
answer, you do know who your neighbors are. They,
in turn, know whether they have cats. So, I send
you the following message:
count_neighbors_with_cats
Having no method of this name, you hand it off to
method_missing for parsing and such. As a result,
each of your neighbors is sent a message such as:
have_cats?
After they respond, you tally and return the results.
Obviously, this could be done without method_missing.
For example, I could send you a Ruby script to eval.
Alternatively, I could send you a YAML (or whatever)
description. Each approach has its own flexibility,
overhead, dangers, etc.
Has anyone done anything like this? I'd love to see
pointers to related work, etc.
-r
--
http://www.cfcl.com/rdm Rich Morin
http://www.cfcl.com/rdm/resume (e-mail address removed)
http://www.cfcl.com/rdm/weblog +1 650-873-7841
Technical editing and writing, programming, and web development
to be modeled as collections of objects. So, you can
ask a node to iterate through its neighbors, etc.
I've been toying with ways to extend this notion, using
(say) method_missing. Here's a hand-waving example,
where "you" are assumed to be a Ruby object:
Let's say that I want to find out how many of your
neighbors have cats. Although you don't know the
answer, you do know who your neighbors are. They,
in turn, know whether they have cats. So, I send
you the following message:
count_neighbors_with_cats
Having no method of this name, you hand it off to
method_missing for parsing and such. As a result,
each of your neighbors is sent a message such as:
have_cats?
After they respond, you tally and return the results.
Obviously, this could be done without method_missing.
For example, I could send you a Ruby script to eval.
Alternatively, I could send you a YAML (or whatever)
description. Each approach has its own flexibility,
overhead, dangers, etc.
Has anyone done anything like this? I'd love to see
pointers to related work, etc.
-r
--
http://www.cfcl.com/rdm Rich Morin
http://www.cfcl.com/rdm/resume (e-mail address removed)
http://www.cfcl.com/rdm/weblog +1 650-873-7841
Technical editing and writing, programming, and web development