public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: kawa@sourceware.org
Subject: new warnings for keywords
Date: Mon, 28 Apr 2014 00:03:00 -0000	[thread overview]
Message-ID: <535D9AD2.6010803@bothner.com> (raw)

The plan is for the syntax for using keywords in Kawa Scheme to be stricter.
I just checked in some warnings; these may switch to errors later.

First, if you want a literal keyword value, you should quote it;
otherwise you will get a warning.

Secondly, only literal unquoted keywords are recognized before keyword arguments
in function calls.  The compiler warns if a literal non-quoted keyword is not
followed by an expression (i.e. something that is not a literal unquoted keyword).
Also, all the keyword-value pairs must be adjacent.  The following are warned about:
   (f x: y: 2)
   (f x: 2 y:)
   (f x: 2 3 y: 4)

For now, this is only partially enforced at rewrite time.  The following is
allowed for now, but will be disallowed in the future:
   (list 1 a: 2 b: 3) ;; bad - instead write: (list 1 'a: 2 'b: 3)

I'm working on a new calling convention (which will support pattern matching ...).
Keyword parameters will only match explicit literal keywords, not expressions that
*happen* to evaluate to keywords.  This can allow better performance, and avoids
errors and accidental matches.

Consider Kawa's general object-allocation syntax:
http://www.gnu.org/software/kawa/Allocating-objects.html
Kawa really needs to know which sub-expressions are keywords, and
which are values.  Currently Kawa decides that a sub-expression is a "keyword"
if it's a QuoteExp whose value is a KeyWord.  This is fragile - if an expression
evaluates to a Keyword, it may behave differently if inlined by the compiler,
and otherwise.

To handle apply-style applications, there will be an "arglist" type, which is like a
list (or vector) but you

This change btw is similar to how Racket handles keywords.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

                 reply	other threads:[~2014-04-28  0:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=535D9AD2.6010803@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.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).