This is the mail archive of the kawa@sourceware.cygnus.com 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]

types of formals in a lambda


Newbie questions:

I'm having problems declaring the type of variables in lambdas

(lambda ((x <String>)) (invoke x 'substring 0 1))

In 1.6.62 the above gives me

java.lang.NullPointerException
	at gnu.bytecode.ConstantPool.addUtf8(Compiled Code)
	at gnu.bytecode.ConstantPool.addString(Compiled Code)
	at gnu.bytecode.CodeAttr.emitPushString(Compiled Code)
	at gnu.expr.CheckedTarget.emitCheckedCoerce(Compiled Code)
	at gnu.expr.CheckedTarget.compileFromStack(Compiled Code)
	at gnu.expr.ReferenceExp.compile(Compiled Code)
	at gnu.expr.PrimProcedure.compile(Compiled Code)
	at gnu.expr.ApplyExp.compile(Compiled Code)
	at gnu.expr.Expression.compileWithPosition(Compiled Code)
	at gnu.expr.Compilation.addClass(Compiled Code)
	at gnu.expr.Compilation.<init>(Compiled Code)
	at gnu.expr.LambdaExp.evalToClass(Compiled Code)
	at gnu.expr.LambdaExp.eval(Compiled Code)
	at gnu.expr.ModuleExp.evalModule(Compiled Code)
	at kawa.Shell.run(Compiled Code)
	at kawa.Shell.run(Shell.java:31)
	at kawa.Shell.run(Shell.java:18)
	at kawa.repl.main(Compiled Code)
	at XinotechGraphAbstractor.main(XinotechGraphAbstractor.java:101)

While the following work fine

(define (blah  (x <String>)) (invoke x 'substring 0 1)))
(let ((x <String> 'asdsdsd)) (invoke x 'substring 0 1))

So what am I doing wrong?


And on a slightly unrelated note, I discovered that

(let ((x  'asdsdsd)) (invoke x 'substring 0 1))

gives a warning about there being no substring method in java.lang.Object
(as it should)  but 

(let ((x  'asdsdsd)) (invoke (as <java.lang.String> x) 'substring 0 1))

didn't. And the following does

(let ((x  'asdsdsd)) 
  (invoke ((lambda (y) <java.lang.String> (as <java.lang.String> y)) x) 
          'substring 0 1))

So I guess I'm a bit confused about how type information in kawa is
used. Any explanations would be appreciated.

suraj
_______________________________________________________________________________
Suraj Acharya                      | 
Xinotech Research,                 | 
Technology Ctr, Suite 213          | 
1313 5th Street S.E.               | voice : (612) 379-3844 ext 25
Minneapolis, MN 55414              | fax   : (612) 379-3833
___________________________________|___________________________________________

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]