This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 12/05/2011 12:30 AM, RÄzvan Rotaru wrote:Hi,
I'm trying to use macros to generate java calls, and have been strugling with this all weekend, but with no success. So, I'd like to ask for some help from more experienced schemers:
The macro should work like this:
(create-object obj-type 'id1 arg1 'id2 arg2 ...)
=>
(obj-type) ;instantiation (*:setId1 arg1) (*:setId2 arg2) ...
Is this possible with kawa? Any hints how to achieve this? The biggest
challenge will probably be to transform 'id-foo in setIdFoo.
Rather than write your own macro, I suggest using the builtin facilities:
http://www.gnu.org/software/kawa/Allocating-objects.html
That makes use of keywords, changing your example to:
(obj-type id1: arg1 id2: arg2 ...)
(doto (java.util.HashMap) (*:put "a" 1) (*:put "b" 2)) => {b=2, a=1}
(doto java.lang.System:out (*:println "Hello") (*:println "World")) Hello World => java.io.PrintStream@4e76fba0
-- Jamison Hope The PTR Group www.theptrgroup.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |