[Issue 8185] Pure functions and pointers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 2 08:20:19 PDT 2012


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


art.08.09 at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |art.08.09 at gmail.com


--- Comment #5 from art.08.09 at gmail.com 2012-06-02 08:22:14 PDT ---
(In reply to comment #0)

> I see the only two ways to document it properly (yes, the main problem is with
> `h` function):

>  * once pure function accepts a pointer it is considered depending on all
> process memory;

That would work, but would probably be too limiting.


 * Allow only dereferencing the pointer, disallow any kind of indexing. Note
it's not trivial, as pointer arithmetic should still work. But probably doable,
by disallowing dereferencing at all, and making a special exception for
accessing via an unmodified argument. This would also have to work recursively,
so it basically comes down to introducing a special kind of pointer, that
behaves a bit more like a reference. The alternatives are the ones you listed,
either banning pointers or assuming the function depends on everything -
neither is really acceptable. A pure function shouldn't deal with unbounded
arrays, so this kind of restriction should be fine (the alternative is to have
to slice everything, which is not a sane solution, eg when working with
pointers to structs)

-- 
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