public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Duncan Mak <duncanmak@gmail.com>
To: kawa mailing list <kawa@sourceware.org>
Subject: Reflection on function argument types
Date: Wed, 28 Dec 2016 05:38:00 -0000	[thread overview]
Message-ID: <CABgWrqqcC2v96NiJ_m7MqFBRtjpbFy0FaoWDKLULmtgS3vTNEQ@mail.gmail.com> (raw)

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.

             reply	other threads:[~2016-12-28  5:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-28  5:38 Duncan Mak [this message]
2017-01-01 18:19 ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABgWrqqcC2v96NiJ_m7MqFBRtjpbFy0FaoWDKLULmtgS3vTNEQ@mail.gmail.com \
    --to=duncanmak@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).