August 20, 2010
On 08/20/2010 02:00 PM, SHOO wrote:
> (2010/08/20 19:35), SHOO wrote:
>> I rewrote:
>> http://ideone.com/5IgYU
>> How about it?
>>
>> P.S. I used an immutable struct for the first time...
>
> Oops, I forgot AUTOSTART.
> http://ideone.com/GiVmf
> AutoStart.yes seems to be slightly redundant.
> How about making a special type AutoStart with typedef and a AUTOSTART
> with constant value(enum)?
> See also: Line415, Line469, Line474-487

About the general usefulness of

enum SomeOption { no, yes }

I suggest we ask the newsgroup. Phobos uses it a fair amount and I haven't heard complaints. I think the basic idiom is a net improvement over bool, but I agree that AutoStart.yes is a bit redundant. But then the solution would be to define a constant like AutoStart and then a constant like NoAutoStart. We're back to square one.

At any rate, please no all-caps constants :o).


Andrei
August 20, 2010
  On 20.08.2010 21:06, Andrei Alexandrescu wrote:
(...)
>
> At any rate, please no all-caps constants :o).
>
http://www.digitalmars.com/d/2.0/dstyle.html:

(...)Submissions to Phobos and other official D source code will follow these guidelines.(...)

Enum member names
    Are in all caps.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100820/deb141ee/attachment.html>
August 20, 2010
That should be changed - it's hardly observed anyway.

Andrei

On 8/20/10 14:11 CDT, Simen Endsj? Haugen wrote:
>   On 20.08.2010 21:06, Andrei Alexandrescu wrote:
> (...)
>>
>> At any rate, please no all-caps constants :o).
>>
> http://www.digitalmars.com/d/2.0/dstyle.html:
>
> (...)Submissions to Phobos and other official D source code will follow
> these guidelines.(...)
>
> Enum member names
>     Are in all caps.
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
August 20, 2010
As part of general clean-up of Phobos, I propose the following:

1.  We update the %(&#$# style guide to not say this.

2.  Anywhere where the OLD_SCHOOL style is used, for example:

enum MyEnum {
    /// Has DDoc.
    FOO,

    /// Has DDoc
    BAR
}

we should simply change to:

enum MyEnum {
    /// Has DDoc
    foo,

    /// Has DDoc
    bar,

    // Undocumented, for compatibility only.
    FOO = foo,

    // Undocumented, for compatibility only.
        BAR = bar
}

I'll be doing this in my dstats library and I think we should gradually do it in Phobos as a "fixing broken windows" when already working on a module.

Also, do we want the first letter to be or not be capitalized?  MyEnum.Foo or MyEnum.foo?  There's inconsistency within Phobos about this, too.



On Fri, Aug 20, 2010 at 3:11 PM, Simen Endsj? Haugen < simen.endsjo at pandavre.com> wrote:

>  On 20.08.2010 21:06, Andrei Alexandrescu wrote:
> (...)
>
>
> At any rate, please no all-caps constants :o).
>
>  http://www.digitalmars.com/d/2.0/dstyle.html:
>
> (...)Submissions to Phobos and other official D source code will follow
> these guidelines.(...) Enum member names Are in all caps.
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100820/20c420b8/attachment.html>
August 20, 2010
I think the code is ready for prime time, modulo the issues below. What do you all think?

Overall this is a good example of modern, idiomatic D code. Everything is clear, simple, and in the right place. Congratulations, Shoo!

*******

Line 21: please add a comment that you're adding this "import inside struct" curiosity with an experimental purpose only.

Line 80: You could an assert or even an enforce here for TICKSPERSPEC.

Line 99: I'm a bit worried that we allow toSeconds for all integer widths. Probably if (isIntegral!T && T.sizeof >= 4) would be better.

Line 170: same concern about toMilliseconds - even bigger because there are lots more milliseconds out there :o).

Line 197: the parameter name should be msec

Line 218: same discussion about the allowed integral types

Line 245: parameter name

Line 431: "Unused"

Line 469: typedef is deprecated (sorry). That's partly why I'm suggesting to go with the enum.

Line 737: I'm afraid you can't put @trusted here because you don't know the safety level of BaseFunc and TargetFunc. You'll need to use @system.

Line 739: Since the two aliases are actually functions, you may want to start their names with lowercase.

Line 762: Beautiful idiom!


Andrei

On 08/20/2010 02:00 PM, SHOO wrote:
> (2010/08/20 19:35), SHOO wrote:
>> I rewrote:
>> http://ideone.com/5IgYU
>> How about it?
>>
>> P.S. I used an immutable struct for the first time...
>
> Oops, I forgot AUTOSTART.
> http://ideone.com/GiVmf
> AutoStart.yes seems to be slightly redundant.
> How about making a special type AutoStart with typedef and a AUTOSTART
> with constant value(enum)?
> See also: Line415, Line469, Line474-487
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
August 20, 2010
On Friday, August 20, 2010 12:06:06 Andrei Alexandrescu wrote:
> At any rate, please no all-caps constants :o).

Really? I would have argued that all-caps constants were good practice. It's quite common in all of the other C-based languages that I've used.

- Jonathan M Davis
August 21, 2010
(2010/08/21 4:06), Andrei Alexandrescu wrote:
> On 08/20/2010 02:00 PM, SHOO wrote:
>> (2010/08/20 19:35), SHOO wrote:
>>> I rewrote:
>>> http://ideone.com/5IgYU
>>> How about it?
>>>
>>> P.S. I used an immutable struct for the first time...
>>
>> Oops, I forgot AUTOSTART.
>> http://ideone.com/GiVmf
>> AutoStart.yes seems to be slightly redundant.
>> How about making a special type AutoStart with typedef and a AUTOSTART
>> with constant value(enum)?
>> See also: Line415, Line469, Line474-487
>
> About the general usefulness of
>
> enum SomeOption { no, yes }
>
> I suggest we ask the newsgroup. Phobos uses it a fair amount and I haven't heard complaints. I think the basic idiom is a net improvement over bool, but I agree that AutoStart.yes is a bit redundant. But then the solution would be to define a constant like AutoStart and then a constant like NoAutoStart. We're back to square one.
>
> At any rate, please no all-caps constants :o).
>
>
> Andrei

All right. I guess that's a way as well... But, does not UpperCamel look like a user-defined type name?
August 20, 2010
That's fine because UpperCamel is a user-defined type, even if it's just an enum.

If you grep std/ for "enum", you'll see that the vast majority of enums have type LikeThis and value likeThis.

As use of constants is very widespread in D compared to other languages (due to extensive static processing), having all caps names all over the place could become annoying.


Andrei

On 08/20/2010 03:36 PM, SHOO wrote:
> (2010/08/21 4:06), Andrei Alexandrescu wrote:
>> On 08/20/2010 02:00 PM, SHOO wrote:
>>> (2010/08/20 19:35), SHOO wrote:
>>>> I rewrote:
>>>> http://ideone.com/5IgYU
>>>> How about it?
>>>>
>>>> P.S. I used an immutable struct for the first time...
>>>
>>> Oops, I forgot AUTOSTART.
>>> http://ideone.com/GiVmf
>>> AutoStart.yes seems to be slightly redundant.
>>> How about making a special type AutoStart with typedef and a AUTOSTART
>>> with constant value(enum)?
>>> See also: Line415, Line469, Line474-487
>>
>> About the general usefulness of
>>
>> enum SomeOption { no, yes }
>>
>> I suggest we ask the newsgroup. Phobos uses it a fair amount and I haven't heard complaints. I think the basic idiom is a net improvement over bool, but I agree that AutoStart.yes is a bit redundant. But then the solution would be to define a constant like AutoStart and then a constant like NoAutoStart. We're back to square one.
>>
>> At any rate, please no all-caps constants :o).
>>
>>
>> Andrei
>
> All right. I guess that's a way as well... But, does not UpperCamel look
> like a user-defined type name?
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
August 20, 2010
On 08/20/2010 02:18 PM, David Simcha wrote:
> As part of general clean-up of Phobos, I propose the following:
>
> 1.  We update the %(&#$# style guide to not say this.

Yes please. Don't forget that you have access to the doc, too!

> Also, do we want the first letter to be or not be capitalized? MyEnum.Foo or MyEnum.foo?  There's inconsistency within Phobos about this, too.

I think MyEnum.foo is best: types start with a capital, values don't.

Andrei
August 20, 2010
On Friday, August 20, 2010 14:05:23 Andrei Alexandrescu wrote:
> That's fine because UpperCamel is a user-defined type, even if it's just an enum.
> 
> If you grep std/ for "enum", you'll see that the vast majority of enums have type LikeThis and value likeThis.
> 
> As use of constants is very widespread in D compared to other languages (due to extensive static processing), having all caps names all over the place could become annoying.

That makes sense, I suppose. I don't entirely like the idea, but having constants in caps all over the place could certainly get annoying. Still, there's only so much that you can do with capitalization to indicate something about a symbol.

- Jonathan M Davis