std.uuid is ready for review
doob at me.com
Sat Feb 11 04:23:07 PST 2012
On 2012-02-10 23:36, Robert Jacques wrote:
> On Fri, 10 Feb 2012 02:56:36 -0600, Jacob Carlborg <doob at me.com> wrote:
>> UUID(Flag!"random", ... ) is just ugly. It's far better to use a
>> static function with a descriptive name.
> These functions are _constructors_; ideally, they should be expressed as
> such. In a managed language, we'd probably for with UUID("random",...).
> And if explicit template ctors were valid syntax, we'd used
> UUID!"random"(...) or UUID!Mt19937() or UUID!randomNumberBased or
> something. There's also the enum/aliases, i.e. UUID(UUID.random) or
> UUID(Enum!"random") or UUID(UUID.Version.randomNumberBased). And at
> least for random, overloading works decently well, i.e. UUID(mySeed) or
> UUID(Mt19937(unpredictableSeed)). My point, or lack thereof, was to
> brainstorm ways of expressing a large variety of construction routines
> _as_ actual constructors.
The first item of the book "Effective Java Programming Language Guide"
says "Consider providing static factory methods instead of constructors".
But if you want to insist on actual constructs, I would prefer
UUID(UUID.random) instead of UUID("random",...) or UUID!"random"(...).
More information about the Digitalmars-d