The more interesting question

Alex Rønne Petersen alex at lycus.org
Tue May 15 11:34:03 PDT 2012


On 15-05-2012 19:29, Gor Gyolchanyan wrote:
 >  >> On Tue, May 15, 2012 at 9:16 PM, Alex Rønne Petersen <alex at lycus.org
 > <mailto:alex at lycus.org>> wrote:
 >  >> Nope. write* perform GC allocation.
 >
 > 1. Give me the top 3 use cases, where GC allocation is intolerable when
 > writing to an output stream.

Who the hell am I or you to dictate use cases? But a few off the top of 
my head:

1) Building without a GC *at all* (and yes, it is possible).
2) When writing high performance tools for doing UNIX-style program 
output piping.

 > 2. writef and friends could get cousins like nogcwritef and
 > nogcwritefln. (see comments beloaw)

Patches welcome.

 > 3. GC can be turned off and gc-allocated memory can be GC.freeed.

Yes, if you alter the implementation. You can't free it from the call 
site. Again, patches welcome.

 > 4. printf could get wrapped to take d-strings by malloc-ing new buffers
 > for the c-strings if necessary.

And just about every C function taking strings, ever. This is a bad 
strategy, and makes D's C interoperability worse.

 >
 >  >> On Tue, May 15, 2012 at 9:16 PM, Alex Rønne Petersen <alex at lycus.org
 > <mailto:alex at lycus.org>> wrote:
 >  >> You're assuming everyone uses Phobos. This is not the case.
 >
 > I'm assuming everyone is sane, because Phobos is called "the standard
 > library" for a damned good reason. For those who don't - they're welcome
 > to use whatever they want and convert d-strings to c-strings any way
 > they choose if necessary.

Yes, let's cripple a systems language for the comfort of the non-systems 
programmers. Excellent idea.

 >
 > --
 > Bye,
 > Gor Gyolchanyan.

PS: Removing null-terminated string literals is not going to fix the 
array slice corner cases by itself. I think this discussion is fairly 
pointless. If you want to fix slices, go all the way with it, not just 
half the way.

Besides, this is probably not going to change anyway. We're focusing on 
stabilizing the language, not changing it.

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list