This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

kawa keyword proposal


I'm leaning towards a charge to Kawa to make it very convenient
to generate XML or HTML.  However, it breaks the equivalency
between the syntaxes 'KEYWORD:' and ':KEYWORD' - the latter
would be a symbol, not a keyword.  I think it is worth it,
but I'm interested in feedback on this idea.

SUMMARY:

* The new form '(define-namespace PREFIX "NAMESPACE-URI")'
defines 'PREFIX' to be a shorthand for the namespace
named by 'NAMESPACE-URI'.  It corresponds to the XML
namespace declaration 'xmlns:PREFIX="NAMESPACE-URI"'.

* The symbol 'PREFIX:LOCAL', assuming PREFIX is bound by
an define-namespace in a closer scope than any explicit
declaration of 'PREFIX:LOCAL', is translated to an element
constructor function.  That is '(P:N "X" (Q:O "Y") "Z")'
generates a data structure (DOM) corresponding to the xml
'<P:N>X<Q:O>Y</Q:O>Z</P:N>'.

* A keyword literal of the form 'KEYWORD:' is translated
to a function that creates an attribute value (a name-value
pair).  That is '(A: "T")' corresponds to the XML form
'A="T"'.  The 'A' is no namespace (the empty namespace).

* The first few arguments of an element constructor
function can be attrribute.  For example the form:
'(P:N (A: "AV") "T")' is equivalent to the XML form
'<P:N A="AV">T</P:N>'.  The result is undefined if an
attribute-valued argument follows non-attribute values.

* The syntax 'PREFIX:KEYWORD:' is translated to a function
that creates an atribute value, but using 'PREFIX' to specify
the namespace of the attribute name.  Thus '(P:N: "T")'
corresponds to the XML form 'P:N="T"'.  The resulting attribute
value can be used an an initial argument in an element
constructor call.

* The new form '(define-default-namespace "NAMESPACE-URI")'
declares the namespace named by 'NAMESPACE-URI' to the default
namespace; see below.  It corresponds to the XML default namespace
declaration 'xmlns="NAMESPACE-URI"'.  The initial (default)
default namespace is the empty namespace (or no namespace).

* The syntax ':LOCAL' is no longer a keyword.  Instead it is a
symbol, treated the same way as 'PREFIX:LOCAL', except using the
default namespace, which is initially the default namespace.

* The forms define-namespace and define-default-namespace are
declarations, and can be used anywhere in a 'body' form,
though it is recommended they be before any statements or
other declarations that make use of the declarations.

INCOMPATIBILITY:

The syntax ':NAME' used to be a keyword, and equivalent to 'NAME:'
It is no longer so.  It is not possible for '(eq? :NAME: NAME")'
if we want the first to evaluate to an element constructor
function, and the second to evaluate to an attribue constructor
function!  So the question is whether new incompatibility
(with past versions of Kawa, Common Lisp, and some other dialects
of Scheme) is worth the convenience.  I think it is, but I'd
like some input on this.

* One idea to make it easier to convert code that uses the
old Common-Lisp-style keyword syntax is this: The form
'(define-default-namespace 'keyword)' defines the "default namespace"
in s special way, such that the form ':LOCAL' evaluates to the
keyword 'LOCAL:'.  However, this mapping is defined in the semantic
analysis phase, not at read time.  Thus at readtime.':LOCAL' returns
a symbol, while 'LOCAL:' is a keyword; they would only *evaluate*
to the same keyword.

	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]