- From: Per Bothner <per@bothner.com>
- Date: Tue, 28 Aug 2001 14:57:27 -0700
- To: www-xml-query-comments@w3.org
- Cc: per@eureka.bothner.com
It would be nice if it were possible to experiment with an XQuery superset that supports patterns, as in xduce. I assume we don't want patterns in XQuery 1.0, but I think it might be nice for a future or exterimental extension. This means being able to bind a variable to some nested type sub-expression. The problem is that the syntax in the published working draft makes this rather awkward. For patterns to be interesting, we DataType should bn abel to be more general type expressions and in the future patterns. But the syntax for Param is 'DataType? Variable'. This is difficult to parse if DataType can be more complex than a simple name. I suggest changing the order: 'Variable DataType?'. I also suggest adding in a delimter which both makes things easier to read and parse, and ties in better with allowing patterns. I suggest '::' as a delimiter, as in: Param := Variable ("::" DataType)? Using colon is familar from many other languages. However, a single colon can be confused with a namespace marker. However, a double colon does not have that problem. Axis specifiers (if they are added to XQuery) use the same syntax, but in a different context, so there is no ambiguity. I also suggest changing typeswitch to: TypeSwitchExpr ::= "typeswitch" "(" Expr ")" CaseClause+ "default" "return" Expr CaseClause ::= "case" [Variable "::"] Datatype "return" Expr Yes, this is a little more verbose in that the Variable has to be specified for each CaseClause rather than sharing a single "as" clause. However, it does allow picking different mnemonic names for each CaseClause, and I think it is more readable. More important, this syntax is extensible to more general patterns, for example: typeswitch ($w) case ($x::type1*),($y::type2) return use($x,$y) case $a::element a($x::type1*,$y::type2) return use($x,$y) default return ... To repeat, I am not proposing general patterns for XQuery 1.0. I am suggesting some syntax tweaks that improve the language in themselves *and* allow experimentation for future extensions using patterns. --Per Bothner per@bothner.com http://www.bothner.com/per/
Received on Tuesday, 28 August 2001 17:56:23 UTC