This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Reflection on function argument types
- From: Duncan Mak <duncanmak at gmail dot com>
- To: kawa mailing list <kawa at sourceware dot org>
- Date: Wed, 28 Dec 2016 00:34:31 -0500
- Subject: Reflection on function argument types
- Authentication-results: sourceware.org; auth=none
Hello all,
Happy holidays!
I'm playing around with Kawa over Christmas break to learn more how
functions are represented in the system.
I wrote the following code:
(import (srfi 1))
(define (foo (a :: integer)) (+ a a))
(define (hello-number (n :: number) (i :: number)) (list "number" n))
(define (hello-string (s :: string)) (list "string" s))
(define (print-types (func :: gnu.mapping.MethodProc))
(display (procedure-property func 'name)) (newline)
(for-each (lambda (t) (display t) (newline))
(map (lambda (i) (func:getParameterType i)) (iota
(func:numParameters))))
(newline))
(print-types foo)
(print-types hello-number)
(print-types hello-string)
I'm surprise to see that the output differs between foo and hello-*:
foo
Type integer
hello-number
ClassType java.lang.Object
ClassType java.lang.Object
hello-string
ClassType java.lang.Object
Why is it that I only see java.lang.Object for the hello-* functions?
Shouldn't number and string show up, like it did for foo?
Thanks!
--
Duncan.