Re: [xsl] Scope of variables

Subject: Re: [xsl] Scope of variables
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 09 May 2003 13:11:21 -0400
At 04:46 AM 5/9/2003, David C wrote:
When I first was shown programming (Fortran at school in the mid 70's)
this aspect of fortran allowing variables to change their definition
was the main "strange" thing about programming languages that all the
books stressed. that programming languages had these strange imperative
features because they were designed to be easily executed by machines
rather than easily understood by humans.

A generation later and things have changed: machines are now more
powerful and so programming languages using more natural declarative
constructs are now feasible. Let the machine do the work and have the
language more suitable for humans. But things are not so simple, it
seems that in the intervening time humans have got used to the
imperative machine-oriented languages and are now unsettled by human
oriented declarative languages. You can't win....

As a footnote to what David says, as a "human-oriented declarative language" XSLT seems to work best (partly; and I say "seem" because (a) this is actually a bit complicated, and (b) I just use these machines I don't build them) when you let it *manage for you* the processing logic of the operation (by letting it execute, where possible, a tree traversal). These are "templates", not "subroutines", and variables are mainly used to hold values that you may want and need, not control the process flow. Not long ago on this list I suggested an XSLT transform needs to be seen as an *output specification*, not a process. (At which someone helpfully mentioned the functional view: you are designing a function in terms of outputs for given inputs, and shouldn't have to worry about how the machine goes about executing it.)


It takes a real shift in mind set, especially when you run into problems for which XSLT *doesn't* give you direct support, and you find yourself implementing loops by recursion, etc. Not that that can't be done -- it can, and has been.

Cheers,
Wendell


___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_ "Thus I make my own use of the telegraph, without consulting the directors, like the sparrows, which I perceive use it extensively for a perch." -- Thoreau


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread