pure or not pure?
guslay
guslay at gmail.com
Wed Apr 9 14:49:12 PDT 2008
Janice Caron Wrote:
> On 09/04/2008, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>
> > as an example of a pure function that takes a pointer to mutable data, but
> > doesn't use the data, i.e. this doesn't ever read or write heap data:
> >
> > pure char *add(char * c, int n) { return c + n;}
>
> Oooh - now that's an interesting one. That one's got me foxed. My
> instinct says it should be disallowed, but I can't quite put my finger
> on why. I'm gonna have to think about that one some more.
>
As long as you stick to pointer arithmetic and don't dereference c, it is pure.
Will it be allowed, that's pure speculation ;)
More information about the Digitalmars-d
mailing list