Re: Declarative constraints in practical terms
Date: 27 Feb 2006 13:47:57 -0800
Message-ID: <1141076877.789050.200720_at_z34g2000cwc.googlegroups.com>
x wrote:
> "David Cressey" <dcressey_at_verizon.net> wrote in message
> news:y0EMf.7424$UN1.5544_at_trndny08...
>
> > Is a FORTRAN statement a statement?
>
> There are people that say this:
>
> max([M],M).
> max([H|T],M):-max(T,M),H<M.
> max([H|T],H):-max(T,N), H>=N.
>
> is more declarative than this:
>
> max([],M,M).
> max([H|T],M,R):-H<M, max(T,M,R).
> max([H|T],M,R):-H>=M, max(T,H,R).
Yes, but those people would be fools :-)
(And those predicates don't even have the same arity, so they can't denote the same relations.)
> I don't know why but I think it has something to do with the fact that in
> some PROLOG implementations the inequality tests are not allowed on unbouded
> variables.
Rougly speaking, a declarative logic language should
- not have side effects;
- be order independent (i.e., respect the commutativity
of conjunction and disjunction and be sound w.r.t.
negation, if supported); and
- functions (if any) should be referentially transparent.
Have a look at Mercury for an example of a pragmatic, general purpose, high performance declarative programming language.
- Ralph