Return ASCII value as uint

Bill Baxter dnewsgroup at billbaxter.com
Thu May 10 16:56:13 PDT 2007


Stewart Gordon wrote:
> "John Ohno" <john.ohno at gmail.com> wrote in message 
> news:f1q9n0$1bd$1 at digitalmars.com...
> <snip>
>> A good general template function (will work for anything that can be 
>> explicity casted to uint, including chars, doubles, and pointers):
>>
>> uint toUint!(T)(T c) {
>>        return (cast(uint)c);
>> }
> 
> Is there really any point using this when you can just cast when you 
> need to?  OK, so it saves two characters where it's used....
> 
> Stewart.

<con>
It makes someone have to go lookup what toUint actually does.  Rather 
than being able to tell immediately by virtue of knowing basic D syntax.

<pro>
toUint(3+foo(x)) is a little easier on the eyes than
cast(uint)(3+foo(x)).

--bb


More information about the Digitalmars-d-learn mailing list