CL implementation questions

Charles Turner chturne@gmail.com
Wed Apr 4 18:38:00 GMT 2012


On 3 April 2012 19:50, Per Bothner <per@bothner.com> wrote:
> On 04/03/2012 10:27 AM, Charles Turner wrote:
>
> // decls is e.g '((integer x) (gnu.lists.sequence y))
>
> I assume you realize you also need to support:  (integer x y)

I had overlooked that, and I've probably overlooked many other aspects
of DECLARE, for the moment I am just trying to get the right idea.

> In the case of declare forms in a <body> you shouldn't need to
> use the LangExp - just call exp2Type directly, as in let.java.

Thanks for this, it's what I needed. I've attached some code showing
what I've done so far. It's not ready for serious consideration, but
I'd like to know if I'm on the right track. I have the following
behaviour with it:

#|kawa:1|# (defun test (x) (declare (integer x)) (+ x 10))
#|kawa:2|# (test 20)
30
#|kawa:3|# (test 50.4)
/dev/stdin:3:7: warning - type gnu.math.DFloNum is incompatible with
required type gnu.math.IntNum
Argument #1 '50.4' to 'test' has wrong type (gnu.math.DFloNum)
(expected: gnu.math.IntNum)
...
#|kawa:4|# (defun test (x) (declare (gnu.lists.Sequence x)) (car x))
#|kawa:5|# (test '(1 2 3))
/dev/stdin:5:1: warning - type gnu.lists.PairWithPosition is
incompatible with required type gnu.math.IntNum
1
#|kawa:6|# (test 10)
Argument #1 '10' to 'test' has wrong type (gnu.math.IntNum) (expected:
gnu.math.IntNum)

Note the strange error message in the last line there, to my surprise,
that happens in Scheme too, which looks like a bug.

I had to override Translator#checkDefaultBinding to get type lookups
working. As with the rest of this patch, it's not nice, just
exploration.

Thanks for your time,
Charles.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: declare.diff
Type: application/octet-stream
Size: 3849 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/kawa/attachments/20120404/f43191ea/attachment.obj>


More information about the Kawa mailing list