[plt-scheme] [redex] matching question

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Fri Jun 4 14:14:54 EDT 2010

Hi,

I have a subtype? metafunction where one clause is as follows:

((subtype? C_0 C_1 CT) 
   #t
   (side-condition (not (equal? (term C_0) (term Object))))
   (where (C_0 C_2 any_1 any_2) (class-lookup C_0 CT))
   (side-condition (not (equal? (term C_0) (term C_1))))
   (side-condition (equal? (term C_2) (term C_1))))

ie. C_0 is subtype of C_1 if C_0 directly inherits from C_1

I find it redundant that I have to write the above, ie. introducing C_2 in the where clause to then check that C_2 and C_1 are equal.

At first I wrote:

((subtype? C_0 C_1 CT) 
   #t
   (side-condition (not (equal? (term C_0) (term Object))))
   (where (C_0 C_1 any_1 any_2) (class-lookup C_0 CT))
   (side-condition (not (equal? (term C_0) (term C_1)))))

putting C_1 directly in the pattern of the where clause, but it did not work (that is to say, it always matched, even if the superclass was different from C_1).

Can someone explain me why this is so?

Thanks!

-- Éric


Posted on the users mailing list.