Idea: Introduce zero-terminated string specifier
Regan Heath
regan at netmail.co.nz
Thu Oct 4 04:06:46 PDT 2012
On Thu, 04 Oct 2012 01:05:14 +0100, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Wed, 03 Oct 2012 08:37:14 -0400, Regan Heath <regan at netmail.co.nz>
> wrote:
>
>> On Tue, 02 Oct 2012 21:44:11 +0100, Steven Schveighoffer
>> <schveiguy at yahoo.com> wrote:
>>> In fact, a better solution would be to define a C string type (other
>>> than char *), and just pretend those system calls return that. Then
>>> support that C string type in writef.
>>>
>>> -Steve
>>
>> :D
>> http://comments.gmane.org/gmane.comp.lang.d.general/97793
>>
>
> Almost what I was thinking.
>
> :)
>
> Though, at that point, I don't think we need a special specifier for
> writef. %s works.
True.
> However, looking at the vast reach of these changes, I wonder if it's
> worth it. That's a lot of prototypes to C functions that have to
> change, and a large compiler change (treating string literals as CString
> instead of char *), just so C strings print out with writef.
That's not the only motivation. The change brings more type safety in
general and should help to catch bugs, like for example the common one
made by people just starting out with D (from a C/C++ background).
> Not to mention code that will certainly break...
Some code will definitely stop compiling, but it's debatable as to whether
this code is not already "broken" to some degree.. it's likely not as
safe/robust as it could be.
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list