From: <don...@is...> - 2017-12-23 21:59:39
|
> > but in (LOOP for (i j k) of-type (fixnum) ...) > > I would expect the atom fixnum to match only i, > > Yes, agree. > > > and I would NOT > > expect of-type (fixnum) to mean the same as of-type (fixnum nil nil) > > so I would expect j and k to be of unspecified type. > > Here you have assumed that the type specifier has a list structure > with some kind of "optional" semantics. However, 6.1.1.7 is clear about: Not sure what you mean by optional semantics - if there is nothing matching some variable then I don't want it assigned a type. > tree n. 1. a binary recursive data structure made up of conses and atoms > So the type specifier (FIXNUM) has to be read/interpreted as (FIXNUM . NIL). Yes, but that's supposed to match a tree of variables, so (fixnum . nil) matches (i . nil) with i matching fixnum. But I don't think that (i j) matches (fixnum) with j matching nil. You could argue that (j) matches nil, but in that case I'd expect that the semantics of a single symbol matching a list should specifically exclude nil as the symbol. Something like this: (defun match(x y) (cond ((and x (symbolp x) y (symbolp y))(list x y)) ((and (consp x) y (symbolp y)) (list x y)) ((and (consp y) y (symbolp x)) (list x y)) ((and (consp x)(consp y)) (cons (match (car x)(car y))(match (cdr x)(cdr y)))))) MATCH [2]> (match '(i j k) 'integer) ((I J K) INTEGER) [3]> (match '(i j k) '(integer)) ((I INTEGER)) |