public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: kawa@sourceware.org
Subject: Re: writing to parameter / type-switch
Date: Sat, 29 Nov 2014 18:07:00 -0000	[thread overview]
Message-ID: <547A0B5E.9060206@bothner.com> (raw)
In-Reply-To: <5479E1AF.4030207@hungry.com>



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/

  reply	other threads:[~2014-11-29 18:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-29 15:09 Seth Alves
2014-11-29 18:07 ` Per Bothner [this message]
2014-11-29 18:26   ` Seth Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=547A0B5E.9060206@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).