Way outside the stuff I "get", Larry mentioned something about a
"transactional model" for flexen.
I keep wanting that to play somewhere in there, but I can't get my
brain around how it should work. Essentially, I keep degenerating into
Prolog. Since I *REALLY* don't wish to change all my perl scripts into
makefiles, that's obviously not the way to go... >:-(
But the idea that the system will constrain prior flexen based on new
data makes me wonder how to provide the new data.
I have this little dental-drill in the back of my head telling me that
your recursion/die (or fail) could be replaced by something like &= and
a while loop, but I can't make it work. Am I barking up the wrong tree?
IOW:
-------------
my $cur = $src;
my @path;
do
{
push @path, $cur;
return undef
unless $cur = any $cur.kids;
}
while ($cur != $dst);
# But now there's all these flexen
# in @path that haven't collapsed, because
# their intermediate values were valid flexen.
my @result;
do
{
unshift @result, $cur;
$cur = pop @path;
$cur &= any $cur.kids == $last;
} while ($cur);
----------------
But that's hideous. Putting the recursion back in:
sub descend($src, $dst)
{
return $dst if $src == $dst;
return undef unless $src.kids;
my @result = descend(any $src.kids, $dst);
# Trying to tie up the flexen. Am I insane?
$src &= any $src.kids == $result[0];
unshift @result, $src;
return @result;
}
=Austin
--- Jonathan Scott Duff <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 30, 2002 at 04:03:55PM +0000, Piers Cawley wrote:
> > Jonathan Scott Duff <[EMAIL PROTECTED]> writes:
> > > Hey, that's neat. Although it looks like it returns the $src when
> there
> > > isn't a path. You probably want it to return undef or something.
> >
> > Nah, it'll die when there isn't a path.
>
> duh! Of course. I was too busy thinking about the recursion.
>
> > > Perhaps where you have "die" there should be something like
> > > $src.collapse or maybe just "return undef".
> >
> > Well, traditionally you have 'fail' there, wants to be some kind of
> > exception, but I'm not entirely sure of what the semantics should
> > be.
>
> In my very-non-exceptional programming, I'd want undef if there
> wasn't
> a path. So, I guess your code is just fine but needs a CATCH block
> in there. The superposition collapses when it finds a path or finds
> that there is no path, no backtracking would be required.
>
> -Scott
> --
> Jonathan Scott Duff
> [EMAIL PROTECTED]
__________________________________________________
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute