[Issue 3057] Add pure annotations to core.stdc.*

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 11 09:47:12 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3057





--- Comment #10 from Brad Roberts <braddr at puremagic.com>  2009-06-11 09:47:11 PDT ---
(In reply to comment #8)
> char* str1=obj.str1;
> const char* str2=obj.str2;
> auto len1=strlen(str2);
> str1[0]=0;
> auto len2=strlen(str2);
> assert(str1!=str2,"pwnd");
> 
> GCC has stricter definition of pure function - a function whose arguments are
> contained in the stack (no reference types), in D this definition is extended
> to include immutable reference types, because they effectively behave as value
> types.

That's fine.  That's not a violation of purity as D has defined it.  Purity is
defined, roughly, as:

  1) does not mutate global state
  2) does not depend on global state

or:
  Depends only on it's inputs and mutates only its output.

strlen is a classic example of a pure function.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list