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]

Re: Adding a new procedure to standard Scheme


On May 27, 2011, at 4:03 PM, Charles Turner wrote:

Hi,

I'm trying to add a new procedure to the standard Scheme in Kawa. The procedure is called write-ss and it's supposed to be a new procedure in the lib.ports file, defined like so,

(define (write-ss value #!optional (out (current-output-port))) :: <void>
(*:format (kawa.standard.Scheme:.sharedWriteFormat) value out))


The idea is for it to pick up a sub-class of DisplayFormat called SSDisplayFormat, so I added the following to kawa.standard.Scheme,

defProcStFld("write-ss", "kawa.lib.ports");

and

public static final AbstractFormat sharedWriteFormat = new SSDisplayFormat(true, 'S');

SSDisplayFormat is just overriding #writeList and #writeObjectRaw from DisplayFormat.

So everything compiles fine, but I get the following exception in the REPL when I try to make sure it's picked up,

#|kawa:3|# write-ss
<unknown>: exception loading 'write-ss' - null

I realise I haven't shown you what's happening in SSDisplayFormat, just because it's quite long and I figured the problem is I'm not registering the new procedure properly in Kawa.

Any thoughts?

Thanks for your time,

Charlie.

That ought to work. I just tried adding a function to ports.scm:


(define (jrh-foo x) ::void
  (display x) (newline))

and to Scheme.java's kawaEnvironment:

defProcStFld("jrh-foo", "kawa.lib.ports");

and after recompiling with ant,

#|kawa:1|# jrh-foo
#<procedure jrh-foo>

Are you sure that kawa/lib/ports.scm got rebuilt after you added your function? If I delete my function but leave the defProcStFld line in Scheme.java and recompile, then I see an error like yours:

#|kawa:1|# jrh-foo
<unknown>: exception loading 'jrh-foo' - null

If I also remove the defProcStFld call (reverting the last of my changes), then the REPL error is different:

#|kawa:1|# jrh-foo
<unknown>: warning - no declaration seen for jrh-foo
unbound location jrh-foo
[followed by stack trace]


The first thing I would try (after double-checking that the spelling matches in both places) would be to do `make clean` or `ant clean` or whatever to be sure that you aren't inadvertently picking up an old class file or an old jar file.


Jamie

--
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]