public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* new warnings for keywords
@ 2014-04-28  0:03 Per Bothner
  0 siblings, 0 replies; only message in thread
From: Per Bothner @ 2014-04-28  0:03 UTC (permalink / raw)
  To: kawa

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/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-28  0:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-28  0:03 new warnings for keywords Per Bothner

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