RE: Arrow operator and empty sequences

> 
> One more note: There has been some discussion to use the placeholder
> syntax for functions:
> 
>    bla => f(?)
> 
> This way, it would have been possible to bind the LHS as argument other
> than the first. As this would have introduced some dependency on the
> higher-order feature, and as it has been argued that the input of a function
> will usually be the first argument, this was declined back then.

Actually, I think the reverse is currently the status quo. The production rules are:

[29]    ArrowExpr    ::=    UnaryExpr ( "=>" ArrowFunctionSpecifier ArgumentList )*
[55]    ArrowFunctionSpecifier    ::=    EQName | VarRef | ParenthesizedExpr

Which I read as: the part after arrow and before the ArgumentList can be any expression, as long as it is parenthesized.  Also, ArgumetList itself is defined as allowing the ArgumentPlaceHolder in any position. So, I believe these are allowed (which includes a variant of your example):

1) bla => concat("a", ?, "b")
2) bla => (xs:string#1)
3) bla => (function($a) { $a * 10 })
4) bla => (function($a) { $a => concat($a, ?, ?) } ("test") )

The last one I think won't throw an exception, because "$a => concat($a, ?, ?)" would translate to concat($a, $a, ?), returning a function with one argument as the result of the inline function. Then "bla => concat("test", "test", ?)"  seems to be the natural result after the inline function is factored away, though the spec does not seem to specify this very clearly.

I think the first three examples speak for themselves. They make more sense if you first mentally assign the rhs to a variable, but the production rules above don't seem to mandate that. 

Cheers,
Abel

Received on Friday, 18 December 2015 00:19:35 UTC