From: Jamison Hope <jrh@theptrgroup.com>
To: Kawa mailing list <kawa@sourceware.org>
Subject: Re: no class-of ?
Date: Sat, 23 Sep 2017 14:31:00 -0000 [thread overview]
Message-ID: <AEA45C97-6B8C-402F-A211-C3C758B136B8@theptrgroup.com> (raw)
In-Reply-To: <332863a5-3fdf-147e-e9c8-23253b0eff31@bothner.com>
On Sep 22, 2017, at 6:26 PM, Per Bothner <per@bothner.com> wrote:
>
> On 09/22/2017 03:18 PM, Jamison Hope wrote:
>> OK, so if I understand correctly, I can't use a macro for this, but what
>> I can do instead is write a function that always gets inlined. The
>> function itself doesn't really have to do anything, because the real
>> work will be done in the validate-apply handler that rewrites the
>> procedure application to a new Expression. And there, I can decide what
>> kind of Expression to construct based upon the Type of the argument
>> expression.
>
> 100% correct.
I found isEofValidateApply, which is extremely similar in form to what I
want, so I started with this:
(import (kawa expressions))
(module-export ensure-boolean validateEnsureBoolean)
(define (ensure-boolean o)
validate-apply: "test:validateEnsureBoolean"
(if o #t #f))
(define-validate validateEnsureBoolean (exp required proc)
((exp:isSimple 1 1)
(exp:visitArgs (get-visitor))
(let* ((e0 (exp:getArg 0))
(t0 (e0:getType)))
(cond ((eq? t0 boolean) e0)
(else exp)))))
But I get a java.lang.Error when I try to compile that:
(compiling test.scm to test)
Exception in thread "main" java.lang.Error: gnu.kawa.lispexpr.LangPrimType does not implement Externalizable
at gnu.expr.LitTable.error(LitTable.java:122)
at gnu.expr.LitTable.writeObject(LitTable.java:282)
at gnu.expr.LitTable.emit(LitTable.java:85)
at gnu.expr.Compilation.generateBytecode(Compilation.java:2015)
at gnu.expr.Compilation.process(Compilation.java:1810)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:310)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:292)
at kawa.repl.compileFiles(repl.java:780)
at kawa.repl.processArgs(repl.java:441)
at kawa.repl.main(repl.java:820)
If I change the test to "(eq? t0 integer)" or "(eq? t0 byte)", then it
compiles without error, so it's something about boolean in particular.
--
Jamison Hope
The PTR Group
www.theptrgroup.com
next prev parent reply other threads:[~2017-09-23 14:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-21 11:11 Sonny To
2017-09-21 15:24 ` Per Bothner
2017-09-22 18:29 ` Jamison Hope
2017-09-22 19:23 ` Per Bothner
2017-09-22 22:18 ` Jamison Hope
2017-09-22 22:26 ` Per Bothner
2017-09-23 14:31 ` Jamison Hope [this message]
2017-09-24 21:52 ` Per Bothner
2017-09-25 16:58 ` Jamison Hope
2017-09-25 17: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=AEA45C97-6B8C-402F-A211-C3C758B136B8@theptrgroup.com \
--to=jrh@theptrgroup.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).