digitalmars.D.bugs - [Issue 3057] New: Add pure annotations to core.stdc.*
- d-bugmail puremagic.com (24/24) Jun 07 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (8/8) Jun 07 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (8/8) Jun 07 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (18/26) Jun 08 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (14/14) Jun 08 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (9/9) Jun 09 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (6/6) Jun 10 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (8/9) Jun 10 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (15/15) Jun 11 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (7/7) Jun 11 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (13/24) Jun 11 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (10/10) Jun 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (7/7) Jun 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3057
- d-bugmail puremagic.com (14/14) Oct 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3057
http://d.puremagic.com/issues/show_bug.cgi?id=3057 Summary: Add pure annotations to core.stdc.* Product: D Version: 2.030 Platform: All OS/Version: All Status: NEW Keywords: patch Severity: enhancement Priority: P2 Component: druntime AssignedTo: sean invisibleduck.org ReportedBy: braddr puremagic.com Created an attachment (id=395) --> (http://d.puremagic.com/issues/attachment.cgi?id=395) Add pure annotations throughout std.core.* I did a quick pass through core.stdc.* to annotate the functions I believe should be pure. I added some comments for several that could be stretched to be pure if we're a little looser with the definition of pure. I skipped over the floating point areas as there's been a good amount of debate that I haven't followed over what to do with them. I defer to Don and Walter on those. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 07 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- (From update of attachment 395) note: I varied the style used to annotate some parts to get a feel for how they looked. A second pass should be done to choose a common style. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 07 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- Created an attachment (id=397) --> (http://d.puremagic.com/issues/attachment.cgi?id=397) same set of changes with pure as after the declaration annotation -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 07 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.auCreated an attachment (id=395)--> (http://d.puremagic.com/issues/attachment.cgi?id=395) [details]Add pure annotations throughout std.core.* I did a quick pass through core.stdc.* to annotate the functions I believe should be pure. I added some comments for several that could be stretched to be pure if we're a little looser with the definition of pure. I skipped over the floating point areas as there's been a good amount of debate that I haven't followed over what to do with them. I defer to Don and Walter on those.Almost all functions in stdc.math cannot possibly be pure, because they set the global 'errno'. (This is part of the reason why it has been worthwhile to re-implement most C math functions in D). There are a few functions (like fpclassify() and the trivial functions which use it) which _could_ legally be marked as pure, but I really don't think that use of stdc.math should be encouraged in any way in D code. So the math stuff is not a TODO list thing, it should stay as impure. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 08 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- Don, Works for me.. core.stdc.math stays impure. I'll put your response in there as a comment to help prevent re-addressing this issue. How about core.stdc.complex? A quick scan of some of the man pages suggest that they don't touch errno. ---- Sean, Any thoughts on the several I added comments to, like all the ones that use the external LC_CTYPE?? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 08 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- I'd consider environment variables to be global state, and so no function using them could be pure. As for some of the ones you'd specifically marked, strftime() uses the LC_TIME category of the current locale, which is global mutable state as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 09 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- String functions are also impure because their arguments can be mutable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 10 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT ---String functions are also impure because their arguments can be mutable.Please be specific. The string functions I marked pure in the attached diffs should be fine. They're taking const non-shared char pointers, which is safe. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 10 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 11 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- assert(str1!=str2,"pwnd"); *fixed -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 11 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT ---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: -------
Jun 11 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- Reference type is an example of global state in the sense that it can change unexpectedly. Dependency on global state is impure because it prevents reordering of function calls and caching function results. My example demonstrates, why strlen calls can't be reordered or cached, which proves its impurity. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 PDT --- strlen is a classic example of a pure function because classic strings are immutable which is not the case for C strings and strlen. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3057 Alex Rønne Petersen <alex lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |alex lycus.org Resolution| |FIXED CEST --- I sent a pull request a while back that added safety, purity, and nothrow annotations throughout core.stdc (not having noticed the patch here). I'll close this, but if it turns out I forgot some annotations, please reopen. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 09 2012