Next in Review Queue: The New std.path

KennyTM~ kennytm at gmail.com
Fri Jul 15 00:15:14 PDT 2011


On Jul 15, 11 10:22, bearophile wrote:
> dsimcha:
>
>> Author's comments -- please read before reviewing:
>
>> Thirdly, I have applied @safe, pure and nothrow wherever possible.
>> There were cases where this was not possible, either due to bugs in DMD
>> (specifically, 5304, 5700 and 5798) or due to functions in other Phobos
>> modules not being properly marked with these attributes.  I have marked
>> these with //TODO comments and will fix them as soon as possible.
>
> Adding pure and nothrow to functions in other Phobos modules is a good thing.
> There are functions like to!int("12") that to become pure require some other functions to become pure first. I think that currently functions that contain enforce can't be pure.
>
> Bye,
> bearophile

The 'enforce' problem is simple. It could be easier replaced by the 
'if(...) throw' construct when not composing, and Don had made a patch 
for bug 5750 to make it pure also.

The big problem is GC.malloc (a.k.a. std.array.uninitializedArray) and 
other GC functions (a.k.a. std.array.appender). They cannot be easily 
replaced without sacrificing performance. (I believe all these allocator 
functions should be made weakly-pure (bug 6151), but so far there isn't 
official decision).

to!int("12") is not pure because of:
  - std.array.front and popFront, because of:
     - std.utf.decode (Phobos pull #80 was rejected), because of:
        - std.exception.enforce (bug 5750 / DMD pull #227)
        - std.conv.to!(string, size_t), because of:
           - GC.malloc, or std.array.uninitializedArray if Phobos pull 
#144 was accepted
        - std.conv.to!(string, const(ubyte)[]), because of:
           - std.conv.to!(string, ubyte), because of 
std.conv.to!(string, uint)
           - std.array.appender, because of:
              - GC.extend
              - GC.qalloc
              - memcpy (just need a 'pure' annotation)
        * All of the above are only because of the error-reporting 
facility. The main content of std.utf.decode is pure and @safe. In 
particular, I don't think it's proper to throw the whole string's 
encoding back to the user.
  - ConvOverflowException.raise, just lacking a 'pure' annotation
  - convError, because of std.conv.to!(string, uint).
  - bug 6265 (DMD pull #222), which prevents 'to' and 'toImpl' to be 
pure even if the function body is all pure.



More information about the Digitalmars-d mailing list