Re: Does Codd's view of a relational database differ from that ofDate&Darwin?[M.Gittens]
Date: Tue, 21 Jun 2005 18:48:41 GMT
> "Jan Hidders" <jan.hidders_at_REMOVETHIS.pandora.be> wrote in message
>>vc wrote: >>>Jan Hidders wrote:
>>>>>for each s in employee print(getName(s), getAge(s), >>>>>getName(getBuilding(getDepartment(s)))) >>>> >>>>What's imperative about this? Where are the assignments? Where are >>>>the while loops? >>> >>>Why, the 'print' word of course as I wrote earlier. >> >>For all intents and purposes the 'print' word is just a keyword in >>DAPLEX and could be easily replaced with something like the 'return' in >>XQuery.
> That is correct. However, in XQuery, the 'return' is just a 'print' (or an
> assignment) in disguise. This 'return' thingy, among others, is what makes
> XQuery 'impure'. Just think about what would be a definition for a function
> called 'return' in a pure FL ? What kind of mapping would it describe ?
The 'return' does not represent a function, but is part of the the for-expression and as such is just a separator that marks where the return-clause begins. A for expression is simply another notation for the monad comprehension, which is just as declarative as the set comprehension or the list comprehension. Or, to explain it in another way, the 'return' keyword plays ruoghly the same role as the 'select' and 'from' keyword in SQL; they are simply markers that indicate where certain subexpressions begin. If I would apply your reasoning there then I would have to ask what the mappings are for 'select', 'from' and 'where', and if those would not exist we would have to conclude that SQL (and also the tuple calculus) are actually not declarative.
>>>>If your above example would be written in ML it would look roughly >>>>the same. >>> >>>I am sure you know that ML is *not* a pure FL and the fragment in >>>question would be imperative there too thanks to 'print' or whatever >>>ML uses. >> >>From the way I used it you might have guessed that I meant pure ML. The >>print statement is only there to say that you return a concatenation of >>values and that you can do in pure ML.
> See above. A 'print', whether it's called 'return' in XQuery, or 'print'
> in Daplex, or 'write', I believe, in ML is an imperative feature whichever
> way you look at it.
No, like I said, I don't need any procedural feature from ML for that. You can also do it in Haskell, or pretty much any other pure functional programming language that is based on monad comprehension or list comprehension.
- Jan Hidders