Re: [xsl] Indirect referencing in XSLT/XPath?

Subject: Re: [xsl] Indirect referencing in XSLT/XPath?
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 5 Apr 2025 22:13:51 -0000
On Sat, 2025-04-05 at 14:35 +0000, Roger L Costello costello@xxxxxxxxx
wrote:
> Hi Folks,
>
> The SNOBOL language has a wicked cool indirect referencing
> capability. Is there an indirect referencing capability in
> XSLT/XPath?
.

In XPath 3 you can use anonymous functions to wrap values and get
indirection using a closure without creating aliasing.

There is also a W3C Note provided by Eliot Kimber, XIndirect
https://www.w3.org/TR/2003/NOTE-XIndirect-20030612/


Indirection can be very powerful, but in a procedural language even
memory-safe aliasing can lead to problems and obscure bugs.

An important programming principle, sometimes called locality of
reference after an earlier observation about memory usage, is that you
should be able to understand code you're looking at without needing to
go elsewhere. In a procedural language this is super important;

   c := 17;
   a := f(b);
doesn't look like it changes b, but it could. And with indirection,
f(b) could change the value of c, too.

In a declarative language like XPath, though, you can't change values,
so indirection and aliasing (b being an alias for c in the above
example perhaps) is less of a problem.


--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

Current Thread