removal of cruft from D

Bill Baxter wbaxter at gmail.com
Mon Nov 23 12:42:50 PST 2009


On Mon, Nov 23, 2009 at 12:34 PM, Pelle Månsson <pelle.mansson at gmail.com> wrote:
> Bill Baxter wrote:
>>
>> On Mon, Nov 23, 2009 at 12:04 PM, Pelle M�nsson <pelle.mansson at gmail.com>
>> wrote:
>>>
>>> dsimcha wrote:
>>>>
>>>> == Quote from retard (re at tard.com.invalid)'s article
>>>>>
>>>>> Mon, 23 Nov 2009 17:14:54 +0000, dsimcha wrote:
>>>>> [snip]
>>>>>>
>>>>>> as opposed to the
>>>>>> Java way of having to use 5 different classes just to read in a file
>>>>>> line by line in the default character encoding.
>>>>>
>>>>> That's a library issue. Has nothing to do with the language.
>>>>
>>>> I agree completely, but for all practical purposes basic parts of the
>>>> standard
>>>> library that are used by almost everyone are part of the language.
>>>> �Heck,
>>>> in many
>>>> languages (D being one of them) you can't even write a canonical hello
>>>> world
>>>> program w/o the standard lib.
>>>
>>> Sure you can!
>>>
>>> extern (C) int puts(char *);
>>> void main() {
>>> � �puts("Hello world!\0".dup.ptr);
>>> }
>>
>> I think he means that the GC from the standard lib will still be there
>> to perform that .dup for you.
>> (You don't need the dup though, btw, string literals are null
>> terminated and can be passed to C funcs as-is).
>>
>> Even without that, the GC doesn't get eliminated from executables just
>> because you don't use it.
>> There's still some hidden calls to gc init routines that go into any D
>> exe.
>>
>> --bb
>
> Fair enough. :) I do think I need the dup, though, since the literal is
> immutable otherwise.

Ah, well, puts is usually declared
        int puts(const char*);
In C libs.  Maybe it's not wise for D to believe such a declaration
though, since it can be easily circumvented.  But it does currently.

--bb



More information about the Digitalmars-d mailing list