From: Per Bothner <per@bothner.com>
To: kawa@sourceware.org
Subject: Re: #t and #f now default to primitive types
Date: Fri, 03 Apr 2015 05:47:00 -0000 [thread overview]
Message-ID: <551E296B.9010104@bothner.com> (raw)
In-Reply-To: <FA011E48-9E8F-447F-9852-47F7486667F0@theptrgroup.com>
On 04/02/2015 10:07 PM, Jamison Hope wrote:
> On Apr 2, 2015, at 9:27 PM, Per Bothner <per@bothner.com> wrote:
>
>> The literals #t and #f are now treated as having primitive boolean types,
>> rather than java.lang.Boolean type. That is the return type of:
>>
>> (define (neg x) (if (>= x 0) #f #t))
>>
>> is boolean rather than java.lang.Boolean.
>>
>> Of course you can specify Boolean explicitly if you want:
>>
>> (define (neg x) ::java.lang.Boolean (if (>= x 0) #f #t))
>
> Thanks, Per. I find it curious that with neg defined as above
> (returning primitive boolean), these return what they do:
>
> (define (f a b) (and (neg a) (neg b)))
> (define (g a b) (if (neg a) (neg b) #t))
> (define (h a b) (or (neg a) (neg b)))
> (define (i a b) (if (neg a) #t (neg b)))
>
> If everything is compiled all together in a module, f and g return
> java.lang.Boolean, h and i return primitive boolean.
>
>
> In the REPL, defining neg and then defining each of those four
> functions, they all return java.lang.Object.
I agree that's not very nice. We can do better. I need to ponder and
experimentmore.
> I still find the type inferencing to be a bit mysterious, I guess the
> actual return type of the neg function isn't always being queried when
> the IfExp's type is calculated?
I'm not sure yet.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
next prev parent reply other threads:[~2015-04-03 5:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 1:27 Per Bothner
2015-04-03 5:07 ` Jamison Hope
2015-04-03 5:47 ` Per Bothner [this message]
2015-04-04 0:32 ` 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=551E296B.9010104@bothner.com \
--to=per@bothner.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).