soundness of combined Coalton/CL codebases #197
Replies: 2 comments 1 reply
-
Looks like this hn comment https://news.ycombinator.com/item?id=28486543 might be the answer. No contracts needed because they are built into CL?
|
Beta Was this translation helpful? Give feedback.
-
Hey @tgbugs, I wanted to comment on the system as it currently works. Coalton can't express types that are a subset of values the way that some contract systems can. This means that numerical ranges and other similar constraints need to be checked within Coalton just like in Common Lisp. It is possible to pass the wrong type to a Coalton function from Common Lisp but the types of errors such as passing a string when a list was expected are much more likely to crash than give an incorrect answer. When Coalton is compiled, Common Lisp type declarations are added to generate more performant code. On high safety settings SBCL will add runtime checks to verify these type declarations. The following code is the identity function specialized to strings.
The codegen for the above function is (COMMON-LISP:DEFUN F (X-700)
(COMMON-LISP:DECLARE (COMMON-LISP:IGNORABLE X-700)
(COMMON-LISP:TYPE COMMON-LISP:SIMPLE-STRING X-700)
(COMMON-LISP:VALUES COMMON-LISP:SIMPLE-STRING
COMMON-LISP:&OPTIONAL))
X-700) If I compile f and then call it with
These runtime checks are sufficient for simple types. However Common Lisp's type system does not have parametric polymorphism G as defined below only takes tuples of Integers, but it can be called from Common Lisp with tuples of any type because the dynamic checks only verify that
If G was instead defined as
Then the type of |
Beta Was this translation helpful? Give feedback.
-
Is Coalton able to deal with soundness issues like those described by Felleisen around 44mins in https://youtu.be/XTl7Jn_kmio?t=2644? From the statement in the introduction
Though note that Coalton will not type-check these function calls for you, since they’re being called as Lisp code.
it seems that there is currently nothing like the Racket contract system that can protect against such issues.Beta Was this translation helpful? Give feedback.
All reactions