[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RE: Declarative programming requires a different mindset

  • From: Kendall Shaw <kshaw@kendallshaw.com>
  • To: "xml-dev\@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Thu, 25 Mar 2010 14:47:54 -0700

Re:  RE: Declarative programming requires a different mindset
"Costello, Roger L." <costello@mitre.org> writes:

[about declarative programming]

I enjoy your various posts with high level questions like this. I hope
you will keep asking them.

The question of what "the definition" of "declarative programming" is,
is unanswerable, I think. People use words as tags to coordinate
discussion of topics. A conversation often takes the form:

Here is a phrase to use as a mnemonic: "..."

Here are more phrases asserting the meaning of the mnemonic phrase.

Here are more phrases that are meant as an invitiation for you to
discuss a topic in terms of those phrases.

In such a discussion you make a point by referencing the mnemonic phrase
and redefining it.

>> A clearer distinction is whether or not the program involves mutable state
> variables.
> Since XSLT variables don't vary, are all XSLT programs declarative?
> Surely that's not the case.

It's worthwhile to think of declarative programming as a style, in my
opinion, and not all XSLT programs are written in a declarative style. A
declarative programming language would be one that makes declarative
programming easier than if it were not a declarative programming language.

A program can have parts that are writte in a declarative style and
parts that are not.

I also think it is worthwhile to think of functional programming and
declarative programing as different things.

Perl is not a functional programming language, but you can write perl in
a declarative style, e.g.:

document(title(), body());

is written in a declarative style.

You can also program in functional programming style using a procedural
language. I suspect you could program in a "less functional" style using
a functional programming language, but I can't think of an example.

> Would someone give an example of XSLT code that is clearly imperative?


<!-- given a matching author author -->
<xsl:variable name="author" select="f:matching-author(.)"/>
<!-- an author-link is the matching author's name and www address -->
  <xsl:copy-of select="$author/name"/>
  <xsl:copy-of select="$author/www"/>

is more declarative and less imperative than:

<!-- output an author-link start tag -->
<xsl:text disable-output-escaping="yes">&lt;author-link></xsl:text>

<!-- get the matching author -->
<xsl:variable name="author" select="f:matching-author(.)"/>

<!-- output it's name -->
<xsl:copy-of select="$author/name"/>

<!-- output it's www address-->
<xsl:copy-of select="$author/ww"/>

<!-- output an author-link end tag -->
<xsl:text disable-output-escaping="yes">&lt;/author-link></xsl:text>

So, I think declarative programming is not a precisely definable
concept. It refers to those parts of a programming style that you
describe as being declarative.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.