- From: Christophe Marchand <cmarchand@oxiane.com>
- Date: Sun, 13 Dec 2020 09:57:36 +0100
- To: public-xslt-40@w3.org
- Message-ID: <5d94a001-47cf-cfd8-0868-6cce9f4767e9@oxiane.com>
Sorry for this response, it was on the wrong thread. I apologize, Christophe Le 13/12/2020 à 00:57, Christophe Marchand a écrit : > > And the groundhog... > > Le 12/12/2020 à 22:55, Michael Kay a écrit : >> Indeed, it's an open question what the context for evaluation of a >> default parameter value expression should be. >> >> We've started implementing core functions in XSLT (for portability), >> so we would like to eliminate the situation where core functions can >> depend on the context in a way that is not allowed for user-defined >> functions. A common case is an argument whose default value depends >> on the default collation in the static context of the caller. >> >> A simple rule that default value expressions are evaluated in the >> context of the caller doesn't work, however: we wouldn't want to >> allow it to reference local variables in the caller's context, or >> (thinking XSLT packages) private functions in the calling package. >> >> Michael Kay >> Saxonica >> >>> On 12 Dec 2020, at 11:33, Reece Dunn <msclrhd@googlemail.com >>> <mailto:msclrhd@googlemail.com>> wrote: >>> >>> A ·focus-dependent· function is a function that accepts the current >>> path focus (context item `.`) as a parameter to the function. >>> Currently this is only supported for built-in functions, but could >>> be useful for user-defined functions. >>> >>> Bounded-variadic functions offer a way of doing this succinctly >>> without any extension to the existing syntax. The logic would be: >>> >>> > If an argument has a default expression equal to the context item, >>> or an expression using the context item (e.g. `./test`), the context >>> item is evaluated at the point at which that argument is evaluated >>> (either from a function call, or a partial function application). >>> >>> This would allow the Functions and Operators specification to use >>> this to define the ·focus-dependent· functions like: >>> >>> | fn:string|(|$arg|| as ||item()? := .|)| as ||xs:string| >>> >>> Note #1: I'm not restricting this to just the context item to >>> support things like: >>> >>> declare function to-xsdate($year := ./year, $month := ./month, >>> $day := ./day) {}; >>> >>> so the following is possible: >>> >>> to-xsdate(2020, 12, 10), $doc//date/to-xsdate() >>> >>> Note #2: I think it makes sense to have the static context bind at >>> the function declaration, and the dynamic context bind at the call >>> site (where the argument is passed to the parameter). >>> >>> Note #3: I'm not sure whether defaults that depend on parameters >>> declared earlier should be valid or not. For example: >>> >>> declare function f($a, $b := $a * 2) {}; >>> >>> Kind regards, >>> Reece >>
Received on Sunday, 13 December 2020 08:58:00 UTC