xsl-list
[Top] [All Lists]

Re: Re: questions about XSLT philosophy: how much is too much?

2003-03-20 14:50:02

"Robert P. J. Day" <rpjday(_at_)mindspring(_dot_)com> wrote in message
news:Pine(_dot_)LNX(_dot_)4(_dot_)44(_dot_)0303200629520(_dot_)3554-100000(_at_)dell(_dot_)(_dot_)(_dot_)
On Thu, 20 Mar 2003, Dimitre Novatchev wrote:

How can a newcomer judge what is the "basic design" and what is
"natural"
for a language?

The fact that you may be experiencing difficulties in understanding
these
does not mean that the language is used unnaturally.

Or shall we start a witch hunt because we do not understand how someone
is
using the language and proclaim this use as "unnatural"?

i didn't mean for this thread to take on a life of its own like
this, and i think you're overreacting to what i wrote.

Didn't you have to tell something similar to other people today?


i never claimed that certain usage of XSLT was "unnatural".  what i
*said* was that, for someone not used to it and coming in with
the understanding that XSLT was being promoted as a *functional*
language, seeing it being used in what appears to be a non-functional
(i.e., procedural) way would *seem* not natural.  that's all,
nothing more.

Can you give examples of using XSLT in non-functional way on xsl-list?


once upon a time, i programmed in prolog, and even taught the
language in a college course in AI.  a lot of students had difficulty
getting their head around their first functional programming language
until they finally clicked on how functional programming worked --
then things went smoothly.

my only point from previous posts was that there is potential
confusion for newcomers like me when we're told up front that
XSLT is functional, then almost immediately see it being used
to solve problems in what appears to be decidedly non-functional
ways.

one example of potential confusion is in tidwell's book, p. 3,
where he *first* writes, "XSLT is heavily influenced by the design
of functional programming languages ... functional programming
languages define programs as a series of functions ..."

and yet, in the very next paragraph, he writes, "Instead of
looping, XSLT uses iteration and recursion."  excuse me but,
where i grew up, iteration is just another word for looping.
and looping sure seems to have a procedural programming history.
and the potential for confusion for beginners increases when
they learn that XSLT does indeed have "if" statements,
case statements and loops.  suddenly, this emphasis on
functional programming seems not so strong anymore.

Even functions have to be built up from some promitive constructs.

If you agree that Haskell is a functional language, there one will find:

if ... then ... else...

case

an iterate() function

some

xxxWhile() and xxxUntil() functions

Ther's even "do"  :o)

The functions mentioned above are from the Standard Haskell Prelude.


finally, not to beat this to death, since i read that it's
coming in XSLT 2.0, but i was amused to see how one finds,
say, the largest value among sibling nodes, which as i recall,
involved comparing to all nodes along the preceding-sibling::
and following-sibling:: axis, yes?

when i saw that, my first reaction was, why is there no max()
function?  i mean, given that XSLT was promoted as being
functional, it struck me as ironic that the one thing that
would have made this solution easy -- a max() function --
wasn't there.

Why should a max() function be provided? In a functional languge only a few
functions need be provided as primitives (not defined by other functions).
Again in Haskell the max() function is not provided as a primitive function
of the language and one can see that it is defined as:

maximum :: Ord a => [a] -> a

maximum = foldl1 max



Where max() is also a non-primitive function:

max x y | x <= y = y

| otherwise = x



Exactly in the same way, it is up to the XSLT programmer to define their
implementation of max or maximum -- this is not difficult.



anyway, i didn't mean for this observation to become such
an issue.

It is an issue, because it is not correct.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




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