chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] advice needed on type-checking of vectors


From: Felix
Subject: [Chicken-hackers] advice needed on type-checking of vectors
Date: Sun, 28 Oct 2012 09:23:33 -0400 (EDT)

Hello!

I would like to be able to generate type checks programmatically from
type-declarations, specifically for a "check-type" form similar to the
one found in Common Lisp, but this may be useful for other things like
specialization. "check-type" is handy, because it provides a common
uniform way of checking argument and other value types and because it
can be integrated with type-analysis (the generated check can be
constructed in a way to maximize utilisation of statically available
type information). The problem I'm facing now is what to do when
doing those type checks at runtime, in particular for large data
structures:

  (check-type (vector-of number) some-variable)

Should this form check each argument for being a number? That could be
rather expensive. CL takes the way out of this dilemma by checking
only the :ELEMENT-TYPE argument given to MAKE-ARRAY (a generic array
with an unspecified element type will always match, at least as I
understand it). 

Any suggestions?


cheers,
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]