<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello, Olaf!<br>
</p>
08.07.2018 23:56, Olaf Klinke wrote:
<blockquote type="cite"
cite="mid:7A9C955B-E3ED-4C06-84CB-6290BD85A6CD@aatal-apotheke.de">
<pre wrap="">Your own example of factorial is very much declarative in the above sense, because it only declares what the factorial function is, in terms of the relationship between factorial(n) and factorial(n-1). Of course the functional programmer must have a mental model of the runtime's behaviour in mind. (Recursively calling the function, in this case.) But what happens on the lower, imperative level when computing factorial(n) is not relevant for the definition of the function.
</pre>
</blockquote>
My point was that in Haskell we define how to calculate result from
arguments, exactly as in C# and with the same pattern-matching. But
in Prolog I coded relation, so Prolog know how to calculate not only
factorial but also argument from the result like we have 2 different
evaluation coded in Prolog. Currently it's obvious: there are
different classification. I showed only what I myself studied as a
student :)<br>
Another interesting note is: are XML, HTML, CSS declarative
language? When I was student they were called formats and not
languages. Because Haskell execution/evaluation is based on lambda
calculus, classical Prolog on formal logic on 1st order predicates,
but on what calculation model are based XML? There are a lot of XML
or CSS parsers on any language :) So, they don't subscribe
evaluation model but only data.<br>
But another contra-example: XML -> DocBook -> Postscript. Is
it format or language? :) I think currently there are a lot of
hybrid-languages: OOP+FP (F#, C#, Ocaml, CL...), FP+PL (Mercury,
Curry...). Also there are a lot of PL libraries, for example:
yieldProlog for Python :) So, there are a lot of cases when it's
difficult to make right classification. So, I understand that
classification becomes more unclear and difficult, that's true. Like
that may be different way to classify them.<br>
Olaf, but I have another question. You was talking about commutative
monads. I check it, something like this:<br>
<pre class="lang-hs prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 5px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; width: auto; max-height: 600px; overflow: auto; background-color: rgb(239, 240, 241); display: block; color: rgb(57, 51, 24); word-wrap: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: rgb(239, 240, 241); white-space: inherit;"><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(16, 16, 148);">
do</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"> a </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"><-</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"> ma
b </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"><-</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"> mb
f a b
is equal to:
</span></code><code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: rgb(239, 240, 241); white-space: inherit;"><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(16, 16, 148);">
do</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"> b </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"><-</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"> mb
a </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"><-</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: rgb(48, 51, 54);"> ma
f a b</span></code>
&& and || are commutative sure. But question is: why in this case in C/C++, Bash (what else) order has matter, even more: order is fixed in standard.
</pre>
`e1 && e2` is equals to `if e1 then e2`. And there is a lot
of code which relies on this. Why they implements boolean operations
in such way? Order has not matter for +, -, *, etc in the same
languages (they are commutative). Why so many languages have not
commutative bool operations? When i think about it, i find next
example: Haskell function is pure, but is it really true? :) In
practical world we can have 2 functions one like `f a b = a + b`.
And another `g` may be some wavelet transformation or calculation of
some super big fractal. No side effects (effects in external world),
but when you evaluate `f` - you can not see effect. But when you
calculate `g` - you can even touch the effect on CPU case with
fingers (it will be hot!) :-) So, there is difference to write `f
&& g` or `g && f`. If some code relies on order of
execution and use `&&` instead of `if` - it has matter. May
be bool operations were not implemented commutative in those
languages because it allows to write "multi-ifs" (a & b & c
& d ...) in short circuit way? I never though about this early
:) I remember that there were orelse and andalso in Basic and
Ocaml... So, seems there is such tradition in CS: to have mandatory
non-commutative and's/or's and optionally commutative and's/or's ?<br>
<br>
===<br>
Best regards, Paul<br>
<code style="margin: 0px; padding: 0px; border: 0px; font-style:
inherit; font-variant: inherit; font-weight: inherit;
font-stretch: inherit; line-height: inherit; font-family:
Consolas, Menlo, Monaco, "Lucida Console",
"Liberation Mono", "DejaVu Sans Mono",
"Bitstream Vera Sans Mono", "Courier New",
monospace, sans-serif; font-size: 13px; vertical-align: baseline;
box-sizing: inherit; background-color: rgb(239, 240, 241);
white-space: inherit;"><span class="pln" style="margin: 0px;
padding: 0px; border: 0px; font-style: inherit; font-variant:
inherit; font-weight: inherit; font-stretch: inherit;
line-height: inherit; font-family: inherit; font-size: 13px;
vertical-align: baseline; box-sizing: inherit; color: rgb(48,
51, 54);"></span></code>
</body>
</html>