Re: prelude extension proposal

From: Sergio Antoy <>
Date: Thu, 13 Oct 2005 14:03:50 -0700

Hi Bernd,

Thanks for your reply.

> There is a subtle problem with your proposal, Sergio. With the definition
> > allValuesOf e = findall (\x -> x=:=e)
> There is a difference between
> e1 = allValuesOf coin
> and
> e2 = findall (\x -> x=:=coin)
> which depends on the implementation of encapsulated search as discussed
> in [1]. The Münster Curry Compiler implements what was called in [1]
> "weak encapsulation" which results in a non-deterministic branching for
> the evaluation for e1 and a deterministic evaluation for e2:
> e1 ~*~> 0 | 1
> e2 ~*~> [0,1]
> In PAKCS ("strong encapsulation") in contrast, allValuesOf will behave
> like you expect, but resulting in different strangenesses for other
> examples.
> I think because of the implementation dependence, the definition should
> not be in the prelude and we should rather think about introducing a
> better approach to encapsulated search like the one proposed in [1].
> [1] Huch, Hanus, Braßel - Encapsulating Non-Determinism in Functional
> Logic Computations - WFLP 2004

Perhaps, the same reason could be advocated for the opposite
decision. Having the function in the prelude with a few lines of
comments explaining its problems might be better that letting the
user, particularly if a student, code the function in his program
and discover the problems the hard way. We, as implementors, look
much better by making the problems clear rather than sweeping them
under the rug.

There is another reason for having this function defined in an
easily accessible place. In an introductory lecture on FLP, I
explain non-determinism as a feature that allows the programmer to
both choose an arbitrary value that will likely be constrained
later and easily compute a set (list, multiset) of values, which
could be ranked, filtered or further processed. Using allValuesOf
instead of findall makes this introductory lecture easier and more
effective, even though in an advanced lecture or course I have to
discuss the problems associated with it.

The real problem is with findall, which is in the prelude. It is
not in making available a convenient function which can be easily
defined everywhere.


curry mailing list
Received on Fr Okt 14 2005 - 08:55:46 CEST

This archive was generated by hypermail 2.3.0 : Sa Jul 24 2021 - 07:15:04 CEST