unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Warning for arity mismatches
@ 2009-11-07 18:38 Ludovic Courtès
  2009-11-07 20:42 ` Andy Wingo
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2009-11-07 18:38 UTC (permalink / raw)
  To: guile-devel

Hello!

There’s a new warning available, ‘-Warity-mismatch’, which warns about
wrong arguments counts, etc.  It currently lacks support for keyword
arguments, which is why it’s not ready yet to compile Guile itself (it
produces erroneous warnings for procedures with keyword arguments.)

I think some of these warnings should really be errors, when there’s
undoubtedly a wrong number of arguments, as in:

  (let ((f (lambda (x) x)))
    (f 1 2 3))

What do you think?

Actually, the tree-il->glil pass surely does a significant part of what
‘arity-mismatch-analysis’ does, and I wonder whether/how this could be
factorized.  For example, tree-il->glil must already diagnose the
problem in the example above.  Andy?

Thanks,
Ludo’.





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

* Re: Warning for arity mismatches
  2009-11-07 18:38 Warning for arity mismatches Ludovic Courtès
@ 2009-11-07 20:42 ` Andy Wingo
  2009-11-08  0:19   ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Wingo @ 2009-11-07 20:42 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

Hi :)

On Sat 07 Nov 2009 19:38, ludo@gnu.org (Ludovic Courtès) writes:

> There’s a new warning available, ‘-Warity-mismatch’, which warns about
> wrong arguments counts, etc.

Cool :)

> It currently lacks support for keyword
> arguments, which is why it’s not ready yet to compile Guile itself (it
> produces erroneous warnings for procedures with keyword arguments.)

Why doesn't it just not warn in that case?

> I think some of these warnings should really be errors, when there’s
> undoubtedly a wrong number of arguments, as in:
>
>   (let ((f (lambda (x) x)))
>     (f 1 2 3))
>
> What do you think?

I think there should be a -Werror compilation argument, but that we
should, by default, compile all expressions. It could very well be that
the user wanted to cause an exception to be raised.

> Actually, the tree-il->glil pass surely does a significant part of what
> ‘arity-mismatch-analysis’ does, and I wonder whether/how this could be
> factorized.  For example, tree-il->glil must already diagnose the
> problem in the example above.  Andy?

See analyze.scm:173. I don't know if I'd bother factorizing anything
more than (args-compatible? proc args).

Andy
-- 
http://wingolog.org/




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

* Re: Warning for arity mismatches
  2009-11-07 20:42 ` Andy Wingo
@ 2009-11-08  0:19   ` Ludovic Courtès
  2009-11-08 10:04     ` Neil Jerram
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2009-11-08  0:19 UTC (permalink / raw)
  To: guile-devel

Hey,

Andy Wingo <wingo@pobox.com> writes:

> On Sat 07 Nov 2009 19:38, ludo@gnu.org (Ludovic Courtès) writes:

[...]

>> It currently lacks support for keyword
>> arguments, which is why it’s not ready yet to compile Guile itself (it
>> produces erroneous warnings for procedures with keyword arguments.)
>
> Why doesn't it just not warn in that case?

It now supports keyword arguments for good, so forget about it.  :-)

>> I think some of these warnings should really be errors, when there’s
>> undoubtedly a wrong number of arguments, as in:
>>
>>   (let ((f (lambda (x) x)))
>>     (f 1 2 3))
>>
>> What do you think?
>
> I think there should be a -Werror compilation argument, but that we
> should, by default, compile all expressions. It could very well be that
> the user wanted to cause an exception to be raised.

Right, why not.  With backwards compatibility in mind, it seems to me
like a reasonable approach

Thanks,
Ludo’.





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

* Re: Warning for arity mismatches
  2009-11-08  0:19   ` Ludovic Courtès
@ 2009-11-08 10:04     ` Neil Jerram
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Jerram @ 2009-11-08 10:04 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

ludo@gnu.org (Ludovic Courtès) writes:

>> I think there should be a -Werror compilation argument, but that we
>> should, by default, compile all expressions. It could very well be that
>> the user wanted to cause an exception to be raised.
>
> Right, why not.  With backwards compatibility in mind, it seems to me
> like a reasonable approach

I agree, this is a nice model of operation.

  Neil




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

end of thread, other threads:[~2009-11-08 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-07 18:38 Warning for arity mismatches Ludovic Courtès
2009-11-07 20:42 ` Andy Wingo
2009-11-08  0:19   ` Ludovic Courtès
2009-11-08 10:04     ` Neil Jerram

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