unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#40294: Documentation for arity procedures doesn't match behavior
@ 2020-03-28 21:42 John Cowan
  2021-05-16  0:07 ` Taylan Kammer
  0 siblings, 1 reply; 3+ messages in thread
From: John Cowan @ 2020-03-28 21:42 UTC (permalink / raw)
  To: 40294

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

Interaction showing the problem


$ guile

GNU Guile 2.2.6

Copyright (C) 1995-2019 Free Software Foundation, Inc.


Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.

This program is free software, and you are welcome to redistribute it

under certain conditions; type `,show c' for details.


Enter `,help' for help.

scheme@(guile-user)> (use-modules (system vm program))

scheme@(guile-user)> program-arities

ERROR: Unbound variable: program-arities. ; should be defined


Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.

scheme@(guile-user)> (arity:nreq +) ; 0 arguments required, correct

$1 = 0

scheme@(guile-user)> (arity:rest? +) ; rest argument, correct

$2 = #f

scheme@(guile-user)> (arity:nreq car) ; 1 argument required, bad

$3 = 0

scheme@(guile-user)> (program-arguments-alist car) ; correct

$4 = ((required _) (optional) (keyword) (allow-other-keys? . #f) (rest .
#f))

scheme@(guile-user)>


The same thing happens in Guile 3, and on both Mac and Linux.

[-- Attachment #2: Type: text/html, Size: 8540 bytes --]

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

* bug#40294: Documentation for arity procedures doesn't match behavior
  2020-03-28 21:42 bug#40294: Documentation for arity procedures doesn't match behavior John Cowan
@ 2021-05-16  0:07 ` Taylan Kammer
  2021-05-16 15:26   ` Taylan Kammer
  0 siblings, 1 reply; 3+ messages in thread
From: Taylan Kammer @ 2021-05-16  0:07 UTC (permalink / raw)
  To: 40294, John Cowan

Hi John!

I can't explain why program-arities isn't defined, but I can tell
that you're not using the arity:foo procedures the way they're meant
to, because their definition indicates that one is supposed to pass
them some sort of arity object that is represented as a list.

The implementations use 'match' to destructure their argument and the
values you're getting correspond to the "else" branch of the match
since you provide procedures as arguments instead of lists. (One could
say the lack of type-checking is a bug on its own right here.)

We seem to have no way of getting an arity list of this sort since
program-arities isn't defined.

I suspect that some corresponding C code was removed at some point
and the module (system vm program) accidentally left in place, as
the Scheme code begins with:

(load-extension (string-append "libguile-" (effective-version))
                "scm_init_programs")

scm_init_programs is from libguile/programs.c and indeed it doesn't
define program-arities.

Will investigate more tomorrow.

--
Taylan





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

* bug#40294: Documentation for arity procedures doesn't match behavior
  2021-05-16  0:07 ` Taylan Kammer
@ 2021-05-16 15:26   ` Taylan Kammer
  0 siblings, 0 replies; 3+ messages in thread
From: Taylan Kammer @ 2021-05-16 15:26 UTC (permalink / raw)
  To: 40294, John Cowan

On 16.05.2021 02:07, Taylan Kammer wrote:
> 
> Will investigate more tomorrow.
> 

It seems that commit 1c33be992e8120abd20add8021e4d91d226f5b6a removed
much of the programs API at the C level but forgot to make the changes
to the corresponding Scheme module.  (It was a big commit, part of
changing the whole VM implementation.)

I wonder if anyone really uses the program API.  It might be best to
deprecate it in favor of an improved procedure metadata API.

--
Taylan





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

end of thread, other threads:[~2021-05-16 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-28 21:42 bug#40294: Documentation for arity procedures doesn't match behavior John Cowan
2021-05-16  0:07 ` Taylan Kammer
2021-05-16 15:26   ` Taylan Kammer

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