std.experimental.checkedint is ready for comments!

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 14 20:42:52 PDT 2016


On 6/14/2016 8:15 PM, tsbockman wrote:
>> N is a basic integral type, it needs a better name than 'N'. How about
>> 'BaseType' or even 'BaseIntegralType'? A complete list of what types are
>> acceptable for 'N' would be desirous, too.
>
> `N` is not a public symbol, and it's used all over the place.

It appears all over the public documentation.

> Do I really need to give it some giant multi-word name?

Something better than 'N'.

> Besides which, Phobos uses single-letter names for template parameter type names
> all over the place.

Generally 'T' is used for 'any type'. 'N' has no corresponding significance.

>> ---
>> 'bscal' is a complete mystery without reading the documentation. Perhaps
>> 'value' instead?
>
> `value` is a very popular name for function parameters and local variables.
> `bscal` needs a more obscure name to prevent the free function version (a shim
> to facilitate uniform treatment of basic integral types and checkedint types in
> generic code) from shadowing or being shadowed by local symbols.
>
> (I originally called it `value`, but changed it once I realized how annoying it
> is not to be able to use that name for anything else in generic code that uses
> `checkedint`.)
>
> Also, I prefer a more unfriendly name for `bscal` to remind people that
> accessing it entails giving up all of the safety benefits of `checkedint`. The
> fact that it's grep-able, too, could be helpful to linters and the like.

Greppability is inddeed a plus, but 'bscal' is needlessly uninformative. Note 
that publicly facing names should not be so.


> I will work on the docs some more.

Thank you.


> * SmartInt.toString(sink, fmt)
> * SafeInt.toString(sink, fmt)
> * checkedint.to()
> * IntFlag.toString(sink, fmt)
> * IntFlags.toString(sink, fmt)

I see no love for output ranges :-(



More information about the Digitalmars-d mailing list