[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Types in Scheme



    Date: Mon, 14 Mar 88 10:11:20 PST
    From: Daniel Weise <daniel at mojave.stanford.edu>

    ... The portable type predicates want to be
    extensional (does this object behave as a pair?), the unportable 
    type predicates are intensional (is this object a pair?).  We obviously
    want to ask both types of questions, ...

I'm sorry, can you tell me again why you'd want to ask the unportable
("intensional") question in portable code, or in any code, for that
matter?  As someone trying to write good code, I want my program to be
as insensitive as possible to the Scheme implementor's representation
decisions -- we all know how perverse implementors can be.  Thus I
should never want to use the "intensional" predicates.  It seems like
this is more of an argument for eliminating the CHAR?  predicate (which
doesn't seem to mean much or me, since character is an "abstract type",
at least as the report stands) than an argument in favor of introducing
a PRIMITIVE-PAIR? predicate (which would be just as useless).

Abstract types may be good for static type checking and program
verification, but I assume we're not talking about that, we're talking
about the dynamic semantics of a dynamically typed language.

The only use I can think of for predicates like CHAR? and PRIMITIVE-PAIR?
is explicit run-time type checking in user code:
	(if (not (char? x))
	    (error "X isn't a character" ...))
This kind of thing always seems kind of fishy to me; how does one decide
when to put these checks in and when not to?  The Scheme programmer
can't really do this in any case, because ERROR isn't standard...

And speaking of CHAR?: I notice that CHAR? is an essential procedure.
To be consistent with my remarks above, I would like to suggest that if
characters are to remain not necessarily distinguishable from numbers,
pairs, etc., then this procedure should be made non-essential, and that
it should be present iff the implementation has a distinct
(extensional?) character type.