Proposal: static template(fail)
Bruce Adams
tortoise_74 at yeah.who.co.uk
Fri Dec 14 01:13:24 PST 2007
On Fri, 14 Dec 2007 07:33:18 -0000, Janice Caron <caron800 at googlemail.com>
wrote:
> On 12/14/07, Robert DaSilva <sp.unit.262+digitalmars at gmail.com> wrote:
>> I've tried it and it didn't work for me.
>
> I didn't think it would.
>
> I didn't get a chance to try before Robert, because of timezone
> differences (I was in bed asleep between the two posts). Still, it's
> nice to see that folk in other parts of the globe can do the
> experiment while I'm tucked up in bed! :-)
>
> I believe that under the current system, if the (T:whatever) rule
> passes, the template is deemed to have matched, and nothing can
> subsequently change its mind. Any compile error encountered from there
> on is considered a real compile error. And I think that's correct
> behavior.
>
> The "template(fail)" suggestion would add a way to say, after the
> event, "I've changed my mind. Please consider this unmatched after
> all".
You've just added our old friend the backtracking algorithm.
It does seem to me that as templates develop further they become more and
more
like a compile time prolog interpreter. This is how prolog predicates
work. Each one is
matched in turn and everything is undone unless it returns true.
More information about the Digitalmars-d
mailing list