Native GTK2 D Bindings

Timon Gehr timon.gehr at gmx.ch
Mon Jan 23 16:21:26 PST 2012


On 01/24/2012 12:18 AM, bearophile wrote:
> Artur Skawina:
>
>> There is no such thing as a language mandated identifier naming convention.
>> If you think otherwise - make the compiler enforce it. :)
>
> There is a D style guide.
>
>
>>> This line of code seems an example for people that like named arguments in D:
>>> gtk.init(null,null);
>>
>> This has nothing to do with named arguments,
>
> It's an example of code where named arguments are useful for the person that reads the code to know what those two arguments are :-)
>
>
>> Requiring explicit casts for most strings is ugly, but not something
>> that can be fixed both safely and cheaply. For a GUI toolkit the
>> amount of casts needed may be acceptable. [1]
>
> But a string is like a 2-tuple, it's not a pointer. It's not meant to allow a cast to pointer.
> So it's better to cast the ".ptr" of an array:
> cast(char*)"Hello World!".ptr
>
> Bye,
> bearophile

This is wrong. String literals are meant to allow a cast to a pointer. 
String literals *implicitly* convert to immutable(char)*. They are 
designed to simultaneously be D style strings and C style strings. There 
is really no need for that .ptr there. It is just noise.


More information about the Digitalmars-d-announce mailing list