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: Questions about #!key arguments


On 10/25/2011 03:27 PM, Per Bothner wrote:
On 10/25/2011 12:01 PM, Jamison Hope wrote:
On Oct 25, 2011, at 2:31 PM, Taylor Venable wrote:
Going back to the first example that works... that's fine when it
stands alone, but if this is inside a define-simple-class I get a
problem when I try to invoke it.

I've never tried to use #!key in class methods, so I can't help you there, sorry. Per?

Getting that to work would be more difficult. The problem is that class methods are supposed to be Java methods, with a calling convention that interoperates well with Java classes. I'm not sure how to do that. It's not a priority - but there should be a decent error message.

Does this go similarly for the #!rest argument in Java methods? The reason I ask is that neither of the following seem to work (or maybe I'm just getting into parts of the system under active development, using trunk r7079):


(define-simple-class bar ()
  ((asdf a #!rest b)
   (format #t "b=~a~%" b)))

(define-simple-class dood ()
  ((asdf a . b)
   (format #t "b=~a~%" b)))

foo.scm:2:3: caught exception in inline-compiler for #<procedure gnu.kawa.functions.AppendValues> - java.lang.NullPointerException
gnu.expr.LambdaExp.enterFunction(LambdaExp.java:1440)
gnu.expr.ClassExp.compileMembers(ClassExp.java:559)
gnu.expr.ClassInitializer.<init>(ClassInitializer.java:16)
gnu.expr.ClassExp.compileSetField(ClassExp.java:797)
gnu.expr.SetExp.compile(SetExp.java:171)
gnu.expr.Expression.compileNotePosition(Expression.java:156)
gnu.expr.Expression.compileWithPosition(Expression.java:127)
gnu.kawa.functions.AppendValues.compile(AppendValues.java:43)
gnu.expr.ApplyExp.inlineCompile(ApplyExp.java:595)
gnu.expr.ApplyExp.compile(ApplyExp.java:190)
gnu.expr.ApplyExp.compile(ApplyExp.java:126)
gnu.expr.Expression.compileNotePosition(Expression.java:156)
gnu.expr.Expression.compileWithPosition(Expression.java:142)
gnu.expr.LambdaExp.compileBody(LambdaExp.java:1641)
gnu.expr.Compilation.generateBytecode(Compilation.java:2021)
gnu.expr.Compilation.process(Compilation.java:1899)
gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:305)
gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
kawa.repl.compileFiles(repl.java:817)
kawa.repl.processArgs(repl.java:444)
kawa.repl.main(repl.java:863)


That error comes from what looks like some code to handle keyword arguments (gnu/expr/LambdaExp.java) - perhaps simply because it fell through the rest parameter handling:

...
1427             else if (max_args < 0 && i == min_args + opt_args)
1428               {
1429                 // This is the "rest" parameter (i.e. following a "."):
1430                 // Convert argsArray[i .. ] to a list.
1431                 code.emitLoad(argsArray);
1432                 code.emitPushInt(i - plainArgs);
1433                 code.emitInvokeStatic(Compilation.makeListMethod);
1434                 stackType = Compilation.scmListType;
1435               }
1436             else
1437               { // Keyword argument.
1438                 code.emitLoad(argsArray);
1439                 code.emitPushInt(min_args + opt_args - plainArgs);
1440                 comp.compileConstant(keywords[key_i++]);
1441                 Expression defaultArg = param.getInitValue();
1442                 Type boxedParamType = paramType instanceof PrimType
1443                     ? ((PrimType) paramType).boxedType()
1444                     : paramType;
...

Thanks in advance.


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