Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 07, 2009 [Issue 3057] New: Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
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: ------- |
June 07, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #1 from Brad Roberts <braddr@puremagic.com> 2009-06-07 14:59:13 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: ------- |
June 08, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #2 from Brad Roberts <braddr@puremagic.com> 2009-06-07 19:40:38 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: ------- |
June 09, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #3 from Don <clugdbug@yahoo.com.au> 2009-06-08 17:45:49 PDT --- (In reply to comment #0) > Created 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: ------- |
June 09, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #4 from Brad Roberts <braddr@puremagic.com> 2009-06-08 21:36:38 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: ------- |
June 09, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #5 from Sean Kelly <sean@invisibleduck.org> 2009-06-09 11:15:06 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: ------- |
June 10, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #6 from Sobirari Muhomori <maxmo@pochta.ru> 2009-06-10 02:58:39 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: ------- |
June 10, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #7 from Brad Roberts <braddr@puremagic.com> 2009-06-10 09:41:38 PDT --- (In reply to comment #6) > 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: ------- |
June 11, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #8 from Sobirari Muhomori <maxmo@pochta.ru> 2009-06-11 04:17:10 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: ------- |
June 11, 2009 [Issue 3057] Add pure annotations to core.stdc.* | ||||
---|---|---|---|---|
| ||||
Posted in reply to braddr@puremagic.com | http://d.puremagic.com/issues/show_bug.cgi?id=3057 --- Comment #9 from Sobirari Muhomori <maxmo@pochta.ru> 2009-06-11 04:19:22 PDT --- assert(str1!=str2,"pwnd"); *fixed -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation