Re: WG: Recovering the once true meaning of type NIL in LOOP

Bruno Haible <[email protected]>
Newsgroups gmane.lisp.clisp.devel
Message-ID <6053218.fuWOXqIrtr@omega>
Jörg wrote on 2017-12-05:
> NIL is a valid type, cf. http://clhs.lisp.se/Body/t_nil.htm but, as useful as
> it is for reasoning about type hierarchies or (VECTOR NIL #), you don't want
> it as type declaration for a variable, because then you can't bind anything
> to that variable!

Correct.

> Consider (macroexpand-1'
> (LOOP for (i j k) of-type (fixnum) across #())

Who says that this should expand to something reasonable?

Citing 6.1.1.7 "Destructuring"
  "When aligning the trees, an atom in the tree of type specifiers that matches
   a cons in the variable tree declares the same type for each variable in the
   subtree rooted at the cons."

So this form declares I as being of type FIXNUM and J and K as being of type NIL.

> Both CLISP and the CMU loop code from the CMU AI repository generate forms like:
> -> (declare (type NIL j)) ; actually (type (or null NIL) j) in clisp
> That's useless.

Correct, that's useless, because the input was useless. The programmer should
have written
  (LOOP for (i j k) of-type (fixnum t t) across #())
or
  (LOOP for (i j k) of-type (fixnum . t) across #())

> NIL has a special meaning in destructuring:
> - as a variable name, that position is ignored (explicitly in CLtL2 and ANSI-CL);
> - as a type, both CLtL2 and ANSI-CL are silent.

Yes.

> So here's a patch for clisp to do the same (even though clisp mostly ignores types).
> With it, clisp and MIT LOOP destructuring look strikingly similar.

What's the point of changing an clisp's LOOP implementation, in an aspect
where it is ANSI CL compliant, to be more like an older implementation that
predates ANSI CL?

Bruno


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.