Adding Java and C++ to the MQTT benchmarks or: How I Learned to Stop Worrying and Love the Garbage Collector

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Thu Jan 9 11:08:42 PST 2014


On Thursday, 9 January 2014 at 18:34:58 UTC, Walter Bright wrote:
> On 1/9/2014 10:18 AM, "Ola Fosheim Grøstad"
>> Why would you do that? You would have to overload cat then.
>
> So you agree that it won't work.

It will work for string literals or for malloc'ed strings, but 
not for both using the same function unless you start to depend 
on the data sections used for literals (memory range testing). 
Which is a dirty tool-dependent hack.

> Overloading doesn't work because a string literal and a string 
> allocated by something else have the same type.

Not if you return your own type, but have the same structure? You 
return a struct, containing a variabled sized array of char, and 
overload on that?

But I see your point regarding literal/malloc, const char* and 
char* is a shady area, you can basically get anything cast to 
const char*.


More information about the Digitalmars-d mailing list