From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41510 invoked by alias); 23 Sep 2017 14:31:17 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 41501 invoked by uid 89); 23 Sep 2017 14:31:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=sk:www.the, sk:wwwthe, HX-HELO:sk:mail.th, H*r:sk:mail.th X-HELO: mail.theptrgroup.com Received: from mail.theptrgroup.com (HELO mail.theptrgroup.com) (71.178.251.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Sep 2017 14:31:15 +0000 Received: from [10.11.21.34] (unknown [10.11.21.34]) by mail.theptrgroup.com (Postfix) with ESMTPS id 508F540242 for ; Sat, 23 Sep 2017 10:31:14 -0400 (EDT) From: Jamison Hope Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: no class-of ? Date: Sat, 23 Sep 2017 14:31:00 -0000 References: <425B3BC8-31F3-4299-ADB1-9E064C1E8D3E@theptrgroup.com> <51a642b1-f20d-9f32-645d-ea96b935e3c2@bothner.com> <332863a5-3fdf-147e-e9c8-23253b0eff31@bothner.com> To: Kawa mailing list In-Reply-To: <332863a5-3fdf-147e-e9c8-23253b0eff31@bothner.com> Message-Id: X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00079.txt.bz2 On Sep 22, 2017, at 6:26 PM, Per Bothner wrote: >=20 > 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. >=20 > 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