unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Procedure arity and documentation
@ 2021-05-26 19:33 Zelphir Kaltstahl
  2021-05-27 10:23 ` Taylan Kammer
  0 siblings, 1 reply; 3+ messages in thread
From: Zelphir Kaltstahl @ 2021-05-26 19:33 UTC (permalink / raw)
  To: Guile User

Hello Guile users!

Today I found the procedure `procedure-minimum-arity`, while tab-completing in
Geiser. I then looked for its documentation in the Guile manual, but could not
find anything about it. (help procedure-minimum-arity) shows:

~~~~
scheme@(guile-user)> (help procedure-minimum-arity)
`procedure-minimum-arity' is a procedure in the (guile) module.

- Scheme Procedure: procedure-minimum-arity proc
     Return the "minimum arity" of a procedure.

     If the procedure has only one arity, that arity is returned as a
     list of three values: the number of required arguments, the number
     of optional arguments, and a boolean indicating whether or not the
     procedure takes rest arguments.

     For a case-lambda procedure, the arity returned is the one with the
     lowest minimum number of arguments, and the highest maximum number
     of arguments.

     If it was not possible to determine the arity of the procedure,
     `#f' is returned.
~~~~

Which helps a lot. I could not understand the procedure's output before that.

Why is the procedure named "minimum", when it also gives the number of optional
arguments and whether it accepts rest arguments?

Is this procedure official API, or is it merely exposed and I should not be
using it?

I am currently reading a book, which uses MIT/GNU Scheme and there exist
`procedure-arity-min` and `procedure-arity-max`. If there is `min`, then I would
expect `max` to be also there. I was a bit confused with Guile only having
`minimum`, but `minimum` not actually being only the minimum, but also option
and rest, which enables one to calculate the maximum.

I also found that the following errors:

~~~~
scheme@(guile-user)> (import (system vm program))
scheme@(guile-user)> (arity:nreq (program-arities (lambda (a b) (+ a b))))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Unbound variable: program-arities

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

Although the manual says:

> The normal case is that a procedure has one arity. For example, (lambda (x)
x), takes one required argument, and that’s it. One could access that number of
required arguments via (arity:nreq (program-arities (lambda (x) x))). Similarly,
arity:nopt gets the number of optional arguments, and arity:rest? returns a true
value if the procedure has a rest arg.

-- https://www.gnu.org/software/guile/manual/guile.html#Compiled-Procedures

Is that a bug, or is it, because I am trying to use it in the REPL and there my
procedure is not compiled?

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl




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

* Re: Procedure arity and documentation
  2021-05-26 19:33 Procedure arity and documentation Zelphir Kaltstahl
@ 2021-05-27 10:23 ` Taylan Kammer
  2021-05-27 19:23   ` Zelphir Kaltstahl
  0 siblings, 1 reply; 3+ messages in thread
From: Taylan Kammer @ 2021-05-27 10:23 UTC (permalink / raw)
  To: Zelphir Kaltstahl, Guile User

On 26.05.2021 21:33, Zelphir Kaltstahl wrote:
> 
> Is that a bug, or is it, because I am trying to use it in the REPL and there my
> procedure is not compiled?
> 
> Best regards,
> Zelphir
> 
There's a relevant bug report I looked into recently:

https://bugs.gnu.org/40294

Quoting myself:

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

-- 
Taylan



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

* Re: Procedure arity and documentation
  2021-05-27 10:23 ` Taylan Kammer
@ 2021-05-27 19:23   ` Zelphir Kaltstahl
  0 siblings, 0 replies; 3+ messages in thread
From: Zelphir Kaltstahl @ 2021-05-27 19:23 UTC (permalink / raw)
  To: Taylan Kammer; +Cc: Guile User

Hi Taylan!

Hm. I see.

I am not quite sure I understand the implications of this. Am I still safe, if I
rely on procedure-minimum-arity, or is that just asking for my code to break at
a later point in time?

Regards,
Zelphir

On 5/27/21 12:23 PM, Taylan Kammer wrote:
> On 26.05.2021 21:33, Zelphir Kaltstahl wrote:
>> Is that a bug, or is it, because I am trying to use it in the REPL and there my
>> procedure is not compiled?
>>
>> Best regards,
>> Zelphir
>>
> There's a relevant bug report I looked into recently:
>
> https://bugs.gnu.org/40294
>
> Quoting myself:
>
> 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.)
>
-- 
repositories: https://notabug.org/ZelphirKaltstahl




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

end of thread, other threads:[~2021-05-27 19:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 19:33 Procedure arity and documentation Zelphir Kaltstahl
2021-05-27 10:23 ` Taylan Kammer
2021-05-27 19:23   ` Zelphir Kaltstahl

unofficial mirror of guile-user@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-user/0 guile-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-user guile-user/ https://yhetil.org/guile-user \
		guile-user@gnu.org
	public-inbox-index guile-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.user
	nntp://news.gmane.io/gmane.lisp.guile.user


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git