The version 13 docs have "In XQuery, functions are called methods if they are embedded in maps."
'backmatter': icc:isBackmatter#1,
....
wouldn't count because it's references, rather than embedded. (I think embedded = anonymous function definition in the map)
Right now that map gets used as
$icc:componentMap($elementName)($element)
to call a function based on which element it is to do something per-element-name to generate an ID component. (Sections have "Sec" prefixes, parts have "Part" prefixes, etc.)
I think the =?> operator doesn't provide a way to do this. The method arrow expects the data is ALSO in the map.
Am I wrong about that?
Thanks!
Graydon
Dear Eliúd,
The syntax of method calls was changed in the 4.0 draft of the specification. The %method annotation was replaced by a "=?>" operator:
let $number := {
'value': 1,
'inc': fn { map:put(., 'value', ?value + 1) }
}
return $number =?> inc()
This is mostly syntactic sugar. In XQuery 3.1, the same code could have been written as:
let $number := map {
'value': 1,
'inc': function($map) { map:put($map, 'value', $map?value + 1) }
}
let $inc-function := $number?inc
return $inc-function($number)
The syntax of the newest version of BaseX is currently documented in the 13 branch of our Wiki [1,2]. Due to numerous changes in the spec, it is about time for a BaseX 13 release.
Hope this helps,
Christian
________________________________________
Gesendet: Donnerstag, 26. März 2026 03:06
An: BaseX
Betreff: [basex-talk] Fwd: Re: [XQST0045] Annotation %method is in reserved namespace.
I tested you suggestions and it's works, the last one with little variation:
let $number := {
'value': 1,
'inc': fn { map:put(., 'value', .?value + 1) }
}
return $number=?>inc()
I was testing 'cause I need to use values objects.
Thanks!!!!!
---------- Forwarded message ---------
Date: Wed, Mar 25, 2026 at 6:55 PM
Subject: [basex-talk] Re: [XQST0045] Annotation %method is in reserved namespace.
On 26/03/2026 01:12, Eliúd Santiago Meza y Rivera via BaseX-Talk wrote:
Hello,
let $vector := {
'x': 5,
'y': 6,
'sum': %method fn() { ?x + ?y }
}
return $vector =?> sum()
In the fiddle the variation
let $vector := {
'x': 5,
'y': 6,
'sum': fn { ?x + ?y }
}
return $vector =?> sum()
works
let $number := {
'value': 1,
'inc': %method fn() { map:put(., 'value', ?value + 1) }
}
return $number?inc()
as does
let $number := {
'value': 1,
'inc': fn { map:put(., 'value', ?value + 1) }
}
return $number=?>inc()
Not sure about the state of the annotation %method
--
LSC Eliud Santiago Meza y Rivera