pure or not pure?
Janice Caron
caron800 at googlemail.com
Thu Apr 10 09:34:29 PDT 2008
On 10/04/2008, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> Then I should be able to do
>
> h(x)
> {
> statement1;
> statement2;
> }
>
> f(x)
> {
> h(x);
> }
>
> g(x)
> {
> h(x);
> }
What you're asking for is what someone else called "amoral" (slightly
pure). You're suggesting that h be pure-/ish/. It doesn't have to be
completely pure per se, but it must be pure /enough/ such that when
embedded within f or g, f and g remain pure.
I have no idea whether or not D will be able to accomodate this
concept. Strictly functional programming doesn't have it. D might or
might not. If we do, I suspect it will require another keyword.
> char[] c = new char[5];
>
> is invalid inside a pure function because the compiler cannot verify
> uniqueness of mutable heap data, right?
No. As I said, new is special. It's integral to the language.
More information about the Digitalmars-d
mailing list