From: Mark H Weaver <mhw@netris.org>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Implement 'scm_c_bind_kwargs' to handle keyword arguments from C
Date: Sat, 06 Apr 2013 21:23:21 -0400 [thread overview]
Message-ID: <87k3oft9py.fsf@tines.lan> (raw)
In-Reply-To: <87fvz35r2v.fsf@pobox.com> (Andy Wingo's message of "Sat, 06 Apr 2013 22:42:16 +0200")
Hi Andy,
Andy Wingo <wingo@pobox.com> writes:
> I'm OK with this in principle, but we shouldagree on names before this
> goes in.
Indeed, I often have trouble coming up with good names. We talked about
it on IRC, and agreed on 'scm_c_bind_keyword_arguments',
'SCM_ALLOW_OTHER_KEYS' and 'SCM_ALLOW_NON_KEYWORD_ARGUMENTS', which are
certainly better than what I had.
>> + va_start (va, allow_other_keys);
>
> "flags", no?
Yes, I noticed that shortly after posting. Oops! :)
>> + for (;;)
>> + {
>> + kw = va_arg (va, SCM);
>> + if (SCM_UNBNDP (kw))
>> + {
>> + /* KW_OR_ARG is not in the list of expected keywords. */
>> + if (!allow_other_keys)
>> + scm_error (scm_keyword_argument_error,
>> + subr, "Unrecognized keyword",
>> + SCM_EOL, SCM_BOOL_F);
>> + break;
>> + }
>
> Don't we need to advance "tail" in the "allow_other_keys" case, to skip
> over the argument value? That is what the bind-kwargs VM op does.
'tail' is not used again. 'rest' is advanced further down in the code.
>> + /* The next argument is not a keyword, or is a singleton
>> + keyword at the end of REST. */
>> + if (!allow_rest)
>> + scm_error (scm_keyword_argument_error,
>> + subr, "Invalid keyword",
>> + SCM_EOL, SCM_BOOL_F);
>> +
>> + /* Advance REST. */
>> + rest = tail;
>
> I think the semantics of rest arguments with keywords is that the rest
> argument *includes* the keywords.
Agreed. 'rest' is not returned, but just used internally to iterate
over the list.
As you suggested, I switched to using an enum for the flags.
You gave your blessing on IRC for me to push this after these updates,
so I did so.
Thanks!
Mark
prev parent reply other threads:[~2013-04-07 1:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-06 19:31 [PATCH] Implement 'scm_c_bind_kwargs' to handle keyword arguments from C Mark H Weaver
2013-04-06 20:42 ` Andy Wingo
2013-04-07 1:23 ` Mark H Weaver [this message]
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=87k3oft9py.fsf@tines.lan \
--to=mhw@netris.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/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).