* writing to parameter / type-switch
@ 2014-11-29 15:09 Seth Alves
2014-11-29 18:07 ` Per Bothner
0 siblings, 1 reply; 3+ messages in thread
From: Seth Alves @ 2014-11-29 15:09 UTC (permalink / raw)
To: kawa
I'm trying to run some code that does roughly this:
(define (foo . opt)
(set! opt (if (null? opt) #f (car opt)))
opt)
(display (foo 1))
(newline)
./kawa-type-switch.scm:7:13: warning - type java.lang.Boolean is
incompatible with required type list
./kawa-type-switch.scm:7:3: warning - cannot convert literal (of type
java.lang.Boolean) to Type list
Value '1' for variable 'opt' has wrong type (integer) (gnu.math.IntNum
cannot be cast to gnu.lists.LList)
at kawa$Mntype$Mnswitch.foo$V(kawa-type-switch.scm:7)
at kawa$Mntype$Mnswitch.applyN(kawa-type-switch.scm:6)
...
I can work around it, but is there a way to make kawa happy with this?
-seth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: writing to parameter / type-switch
2014-11-29 15:09 writing to parameter / type-switch Seth Alves
@ 2014-11-29 18:07 ` Per Bothner
2014-11-29 18:26 ` Seth Alves
0 siblings, 1 reply; 3+ messages in thread
From: Per Bothner @ 2014-11-29 18:07 UTC (permalink / raw)
To: kawa
On 11/29/2014 07:09 AM, Seth Alves wrote:
> I'm trying to run some code that does roughly this:
>
> (define (foo . opt)
> (set! opt (if (null? opt) #f (car opt)))
> opt)
>
> (display (foo 1))
> (newline)
>
> ./kawa-type-switch.scm:7:13: warning - type java.lang.Boolean is incompatible with required type list
> ./kawa-type-switch.scm:7:3: warning - cannot convert literal (of type java.lang.Boolean) to Type list
> Value '1' for variable 'opt' has wrong type (integer) (gnu.math.IntNum cannot be cast to gnu.lists.LList)
> at kawa$Mntype$Mnswitch.foo$V(kawa-type-switch.scm:7)
> at kawa$Mntype$Mnswitch.applyN(kawa-type-switch.scm:6)
> ...
>
> I can work around it, but is there a way to make kawa happy with this?
The reason is that Kawa automatically sets the type of a dotted parameter to 'list'.
Conceptually the fix is to implicit treat:
(define (foo . opt) ...)
as:
(define (foo . incoming-opt::list)
(let ((opt incoming-opt)) ...))
We're not going to make this change until I make make sure no
extra code is generated in the normal case where the parameter isn't assigned to.
That isn't in principle difficult, but it means either awkwardly adding a
Scheme dependency in the non-Scheme-specific code - or Kawa needs to be
smart enough to combine variables when variable2 is initialized to variable1
and neither is further modified.
Shortly I will be working on changing how parameter are processed, partly to
support ML-style pattern matching. It's not a priority right now.
If you want to enter a bug in the Kawa BugZilla that will make it easier
to not forget it ...
I'm not considering this a high-priority bug because of the easy work-around and
because frankly I consider the example pretty horrible style ...
--
--Per Bothner
per@bothner.com http://per.bothner.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: writing to parameter / type-switch
2014-11-29 18:07 ` Per Bothner
@ 2014-11-29 18:26 ` Seth Alves
0 siblings, 0 replies; 3+ messages in thread
From: Seth Alves @ 2014-11-29 18:26 UTC (permalink / raw)
To: kawa
On 11/29/2014 10:07 AM, Per Bothner wrote:
>
> I'm not considering this a high-priority bug because of the easy
> work-around and
> because frankly I consider the example pretty horrible style ...
Agreed. This code is from... 1995. I'll file a bug report.
-seth
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-29 18:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-29 15:09 writing to parameter / type-switch Seth Alves
2014-11-29 18:07 ` Per Bothner
2014-11-29 18:26 ` Seth Alves
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).