[Python-3000] Brainstorming: literal construction hooks

Guido van Rossum guido at python.org
Sat Apr 22 17:17:59 CEST 2006


On 4/22/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Guido van Rossum wrote:
>
> > It's an interesting idea; it's been brought up before but nobody AFAIK
> > has ever implemented it. I like the scoping requirement.
>
> can we add support for XML literals while we're at it?
>
>     http://effbot.org/zone/idea-xml-literal.htm

Javascript has an ECMA standardized extension that supports this
(ECMA-357 or E4X).

Groovy has a different approach that doesn't blend the two syntaxes,
but rather gives you more native syntax for constructing DOM trees (or
event streams; it wasn't clear from the description I saw today). That
makes perhaps more sense; it avoids the lexical ambiguities and a
parentheses-based syntax is easier to type than XML. Maybe this
example (which I am making up) suffices:

frag1 = element["some content"]

frag2 = element["some content",
                             child(attribute='value')["spam & egg"]]

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list