public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Problem with storing types in variables
@ 2019-07-09 18:57 Peter
  2019-07-09 22:18 ` Per Bothner
  2019-07-10  3:02 ` Per Bothner
  0 siblings, 2 replies; 3+ messages in thread
From: Peter @ 2019-07-09 18:57 UTC (permalink / raw)
  To: kawa mailing list

Hello ;)

A quick question:

 (float[][] length: 10)

works fine, as expected, however:

 (define faa float[][])
 (faa length: 10)

does not. This used to work in earlier versions of kawa, but now I get:

java.lang.ClassCastException: don't know how to coerce gnu.math.IntNum to float[]
	at gnu.bytecode.ObjectType.coerceFromObject(ObjectType.java:182)
	at gnu.kawa.reflect.Invoke.applyToObject(Invoke.java:191)
	at gnu.kawa.functions.ApplyToArgs.applyRest(ApplyToArgs.java:157)
	at gnu.kawa.functions.ApplyToArgs.applyToConsumerA2A(ApplyToArgs.java:134)
	at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
	at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:342)
	at gnu.expr.ModuleExp.evalModule(ModuleExp.java:211)
	at kawa.Shell.run(Shell.java:283)
	at kawa.Shell.run(Shell.java:196)
	at kawa.Shell.run(Shell.java:183)
	at kawa.repl.processArgs(repl.java:714)
	at kawa.repl.main(repl.java:820)

How do I call the constructor correctly, if it is called via a variable?

Thanks for any help with this!

Greetings, Peter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problem with storing types in variables
  2019-07-09 18:57 Problem with storing types in variables Peter
@ 2019-07-09 22:18 ` Per Bothner
  2019-07-10  3:02 ` Per Bothner
  1 sibling, 0 replies; 3+ messages in thread
From: Per Bothner @ 2019-07-09 22:18 UTC (permalink / raw)
  To: Peter, kawa mailing list

On 7/9/19 11:57 AM, Peter wrote:
> Hello ;)
> 
> A quick question:
> 
>   (float[][] length: 10)
> 
> works fine, as expected, however:
> 
>   (define faa float[][])
>   (faa length: 10)
> 
> does not. This used to work in earlier versions of kawa, but now I get:

Currently, the length keyword is only supported when the array constructor
expression is inlined (optimized at compile-time).  However, it does not
work when array construction is called in "reflexive" mode at run-time.
(This broke when Kawa's 'apply' calling convention was re-done.)

A work-around is to use define-constant or the ! operator:
    (define-constant faa float[][])
or:
    (! faa float[][])

This allows the compiler to optimize the use of faa.

I'm working on fixing this.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problem with storing types in variables
  2019-07-09 18:57 Problem with storing types in variables Peter
  2019-07-09 22:18 ` Per Bothner
@ 2019-07-10  3:02 ` Per Bothner
  1 sibling, 0 replies; 3+ messages in thread
From: Per Bothner @ 2019-07-10  3:02 UTC (permalink / raw)
  To: Peter, kawa mailing list

On 7/9/19 11:57 AM, Peter wrote:
> however:
> 
>   (define faa float[][])
>   (faa length: 10)
> 
> does not. This used to work in earlier versions of kawa, but now I get:
> 
> java.lang.ClassCastException: don't know how to coerce gnu.math.IntNum to float[]

Should work now (in git master).
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-10  3:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-09 18:57 Problem with storing types in variables Peter
2019-07-09 22:18 ` Per Bothner
2019-07-10  3:02 ` Per Bothner

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).