Re: Type strategy for Scheme Lassi Kortela 10 Nov 2022 09:49 UTC

>> (vector 1 'foo '())

Cannot be typed in H-M.

The type of (values 1 'foo '()) would be (values integer symbol (list 'a)).

>> #0=(#0#)

Does not terminate / "bottom" of some flavor.

>> (syntax (let ((x 1)) (+ x x)))

Syntax object.

> And, not to forget, what if you do (vector-set! x 1 "bar") later in the
> program.

Common Lisp:

 > (setf (aref (make-array 3 :element-type '(unsigned-byte 8)) 0) "new
value")

*** - SYSTEM::STORE: "new value" does not fit into #(0 0 0), bad type

The Scheme equivalent of (make-array 3 :element-type '(unsigned-byte 8))
is (make-u8vector 3).

You can have a general vector type (vector any) if type system has an
"any" type, as CL does. Racket has one too; I'm reading the materials
linked by Philip to try to understand how it combines the "any" type
with type inference.