[Xpath-ng] List constructor syntax
Jeni Tennison
jeni at jenitennison.com
Wed Dec 4 11:15:51 MST 2002
Hi David,
> But if lists are just lists with no magical behavior (the way I want
> them) you'll want the ability to create singleton lists. Here are a
> couple of possibilities:
>
> Have a list function which takes zero or more arguments:
> list (1, 17) -- list with two items
> list (17) -- list with one item
> list () -- empty list
>
> This solution could be used alone or as a complement to the comma
> operator solution.
>
> Use square brackets or braces
> [1, 17] or {1, 17}
> [17] or {17}
> [] or {}
>
> Use parenthesis prefixed by a special character e.g. $
> $(1, 17)
> $(17)
> $()
>
> A variant of this and the function solution would be to
> name the function 'L' as in L(1, 17) and thus decrese the verbosity,
> but on the other hand it would be inconsistent with other core
> functions, which start with a lowercase character.
>
> My gut feeling is that the first list function solution is the
> cleanest and simplest. I could live with the square bracket version
> too, but I believe many will consider it too close to the filter
> syntax.
I don't think we should use square or curly braces because []s are
used for predicates and {}s are used in XSLT for attribute value
templates so I think we should avoid them.
I think that we should use a comma operator to create lists with
several items, so you can just do:
(1, 17)
to create a list with two items. That leaves how to create a list with
one item or no items. I prefer the list() function as a way of doing
that. I'd rather not use characters if we don't need to, and I don't
think that creating lists with 0 or 1 items is going to be required
that much, so the extra 3 characters involved in a list() function
don't seem to be a burden.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
More information about the Xpath-ng
mailing list