From: <craven@gmx.net>
To: kawa mailing list <kawa@sourceware.org>
Subject: Problem with macro that expands to define-simple-class
Date: Wed, 05 Sep 2012 08:40:00 -0000 [thread overview]
Message-ID: <87k3w8q2ve.fsf@nexoid.at> (raw)
I've run into a problem with a syntax-rules macro that expands to a
DEFINE-SIMPLE-CLASS statement:
(define-syntax define-simple-database-helper
(syntax-rules ()
((_ name log-name version (table-name create-statement) ...)
(define-simple-class name
(<android.database.sqlite.SQLiteOpenHelper>)
((*init* (context :: <Context>))
(invoke-special <android.database.sqlite.SQLiteOpenHelper> (this) '*init* context log-name #!null version))
((onCreate (db :: <android.database.sqlite.SQLiteDatabase>)) ::
void
(for-each (lambda (sql)
(db:execSQL sql))
(list create-statement ...)))
((onUpgrade (db :: <android.database.sqlite.SQLiteDatabase>) (old-version :: int) (new-version :: int))
(for-each (lambda (name)
(db:execSQL (format "drop table if exists ~a" name)))
(list table-name ...))
(onCreate db))))))
Usage would be like this:
(define-simple-database-helper "games" "database" 1
("categories" "create table categories (_id text primary key, name text not null);")
("games" "create table games (_id text primary key, name text not null);"))
But loading the definition into svn kawa as of right now and using
(require 'syntax-utils) and EXPAND shows:
(let ((games #!undefined))
(set games (lambda (*init* onCreate onUpgrade) #!null)))
Is there a way to write this macro (using syntax-rules)?
Thanks for any help!
Peter
next reply other threads:[~2012-09-05 8:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 8:40 craven [this message]
2012-09-05 16:08 ` 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=87k3w8q2ve.fsf@nexoid.at \
--to=craven@gmx.net \
--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).