From: Daniel Hartwig <mandyke@gmail.com>
To: Daniel Llorens <daniel.llorens@bluewin.ch>
Cc: guile-user@gnu.org
Subject: Re: case-lambda* question
Date: Tue, 13 Nov 2012 10:46:49 +0800 [thread overview]
Message-ID: <CAN3veRc1TK-YdZdVu1_cy9iFzMhiT146oCeWYmiOCR+z9mraAw@mail.gmail.com> (raw)
In-Reply-To: <C508337D-C585-45A7-8C63-4AC151A38CDA@bluewin.ch>
On 12 November 2012 21:54, Daniel Llorens <daniel.llorens@bluewin.ch> wrote:
>
> (define f
> (case-lambda*
> ((a b c #:key x) 3)
> ((a #:key x) 1)))
>
> scheme@(guile-user)> (g 0 #:x 1)
> $1 = 3
Because “0 #:x 1” is a valid match for “a b c”, you should rearrange
the case-lambda clauses.
When the doc. states keyword arguments do not contribute to the
success of a match, it refers only to keyword arguments in the
case-lambda clause, not at the call site. This makes sense, otherwise
it would inhibit writing functions that detect keywords internally
from their rest arguments.
scheme@(guile-user)> (define g
(case-lambda*
((a #:key x) 1)
((a b c #:key x) 3)))
scheme@(guile-user)> (g 0 #:x 1)
$2 = 1
However, trying to call with three arguments then triggers an error,
and I am not sure why:
scheme@(guile-user)> (g 1 2 3)
<unnamed port>:46:1: In procedure g:
<unnamed port>:46:1: In procedure #<procedure g (a #:key x) | (a b c
#:key x)>: Invalid keyword
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In current input:
46:1 0 (g 1 #<undefined> 2 3)
Definitely you need to rearrange the clauses. About this error, I don't know!
Regards
next prev parent reply other threads:[~2012-11-13 2:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-12 13:54 case-lambda* question Daniel Llorens
2012-11-13 2:46 ` Daniel Hartwig [this message]
2012-11-14 0:55 ` Germán A. Arias
2012-11-14 10:20 ` Daniel Llorens
2012-11-14 17:53 ` Germán A. Arias
2012-11-15 1:01 ` Germán A. Arias
2013-01-14 9:41 ` Andy Wingo
2012-11-15 1:22 ` Daniel Hartwig
2012-11-19 9:43 ` Daniel Llorens
2013-01-14 9:39 ` Andy Wingo
2013-01-14 10:39 ` Andy Wingo
2013-01-14 12:22 ` Ludovic Courtès
2013-01-15 12:01 ` Daniel Llorens
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAN3veRc1TK-YdZdVu1_cy9iFzMhiT146oCeWYmiOCR+z9mraAw@mail.gmail.com \
--to=mandyke@gmail.com \
--cc=daniel.llorens@bluewin.ch \
--cc=guile-user@gnu.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).