Re: toStringz or not toStringz

2011-07-14 Thread Regan Heath
On Thu, 14 Jul 2011 12:30:24 +0100, Steven Schveighoffer wrote: On Thu, 14 Jul 2011 05:53:47 -0400, Regan Heath wrote: On Wed, 13 Jul 2011 19:31:42 +0100, Steven Schveighoffer wrote: On Wed, 13 Jul 2011 13:32:56 -0400, Regan Heath wrote: On Wed, 13 Jul 2011 17:00:39 +0100, Steven

Re: toStringz or not toStringz

2011-07-14 Thread Steven Schveighoffer
On Thu, 14 Jul 2011 05:53:47 -0400, Regan Heath wrote: On Wed, 13 Jul 2011 19:31:42 +0100, Steven Schveighoffer wrote: On Wed, 13 Jul 2011 13:32:56 -0400, Regan Heath wrote: On Wed, 13 Jul 2011 17:00:39 +0100, Steven Schveighoffer wrote: How does your proposal know that a char *

Re: toStringz or not toStringz

2011-07-14 Thread Regan Heath
On Wed, 13 Jul 2011 19:31:42 +0100, Steven Schveighoffer wrote: On Wed, 13 Jul 2011 13:32:56 -0400, Regan Heath wrote: On Wed, 13 Jul 2011 17:00:39 +0100, Steven Schveighoffer wrote: How does your proposal know that a char * is part of a heap-allocated array? If you are assuming t

Re: toStringz or not toStringz

2011-07-13 Thread Steven Schveighoffer
On Wed, 13 Jul 2011 13:32:56 -0400, Regan Heath wrote: On Wed, 13 Jul 2011 17:00:39 +0100, Steven Schveighoffer wrote: How does your proposal know that a char * is part of a heap-allocated array? If you are assuming the only case where char * is passed will be arr.ptr, then that does

Re: toStringz or not toStringz

2011-07-13 Thread Regan Heath
On Wed, 13 Jul 2011 17:00:39 +0100, Steven Schveighoffer wrote: On Wed, 13 Jul 2011 10:59:27 -0400, Regan Heath wrote: I am suggesting the compiler will perform a special operation on all char* parameters passed to extern "C" functions. The operation is a toStringz like operation whic

Re: toStringz or not toStringz

2011-07-13 Thread Jonathan M Davis
On 2011-07-13 09:00, Steven Schveighoffer wrote: > On Wed, 13 Jul 2011 10:59:27 -0400, Regan Heath > > wrote: > > I am suggesting the compiler will perform a special operation on all > > char* parameters passed to extern "C" functions. > > > > The operation is a toStringz like operation which is

Re: toStringz or not toStringz

2011-07-13 Thread Steven Schveighoffer
On Wed, 13 Jul 2011 10:59:27 -0400, Regan Heath wrote: I am suggesting the compiler will perform a special operation on all char* parameters passed to extern "C" functions. The operation is a toStringz like operation which is (more or less) as follows: 1. If there is a \0 character i

Re: toStringz or not toStringz

2011-07-13 Thread Regan Heath
Ok, it's clear there has been some confusion over what exactly I am suggesting. I am not suggesting the compiler simply insert calls to the existing toStringz function as it appears the function does not, or cannot do what I am imagining. I am suggesting the compiler will perform a specia

Re: toStringz or not toStringz

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 13:00:41 -0400, Regan Heath wrote: On Tue, 12 Jul 2011 17:09:04 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 11:41:56 -0400, Regan Heath wrote: On Tue, 12 Jul 2011 15:59:58 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 10:50:07 -0400, Regan

Re: toStringz or not toStringz

2011-07-12 Thread Regan Heath
Gah.. bad grammar.. 1/2 baked sentences.. On Tue, 12 Jul 2011 18:00:41 +0100, Regan Heath wrote: On Tue, 12 Jul 2011 17:09:04 +0100, Steven Schveighoffer wrote: No, it wouldn't compile. char[] does not cast implicitly to char *. (if it does, that needs to change). Replace foo with foo

Re: toStringz or not toStringz

2011-07-12 Thread Regan Heath
On Tue, 12 Jul 2011 17:09:04 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 11:41:56 -0400, Regan Heath wrote: On Tue, 12 Jul 2011 15:59:58 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 10:50:07 -0400, Regan Heath wrote: What if you expect the function is expect

Re: toStringz or not toStringz

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 11:41:56 -0400, Regan Heath wrote: On Tue, 12 Jul 2011 15:59:58 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 10:50:07 -0400, Regan Heath wrote: What if you expect the function is expecting to write to the buffer, and the compiler just made a copy of it

Re: toStringz or not toStringz

2011-07-12 Thread Regan Heath
On Tue, 12 Jul 2011 16:04:15 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 10:59:58 -0400, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 10:50:07 -0400, Regan Heath wrote: and in both cases, toStringz would do nothing as foo is zero terminated already (in both cases), or

Re: toStringz or not toStringz

2011-07-12 Thread Regan Heath
On Tue, 12 Jul 2011 15:59:58 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 10:50:07 -0400, Regan Heath wrote: What if you expect the function is expecting to write to the buffer, and the compiler just made a copy of it? Won't that be pretty surprising? Assuming a C functio

Re: toStringz or not toStringz

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 10:59:58 -0400, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 10:50:07 -0400, Regan Heath wrote: and in both cases, toStringz would do nothing as foo is zero terminated already (in both cases), or am I wrong about that? In neither case are they required to be nul

Re: toStringz or not toStringz

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 10:50:07 -0400, Regan Heath wrote: On Tue, 12 Jul 2011 15:18:04 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 09:54:15 -0400, Regan Heath wrote: On Fri, 08 Jul 2011 18:59:47 +0100, Walter Bright wrote: On 7/8/2011 4:53 AM, Regan Heath wrote: On Fri,

Re: toStringz or not toStringz

2011-07-12 Thread Regan Heath
On Tue, 12 Jul 2011 15:18:04 +0100, Steven Schveighoffer wrote: On Tue, 12 Jul 2011 09:54:15 -0400, Regan Heath wrote: On Fri, 08 Jul 2011 18:59:47 +0100, Walter Bright wrote: On 7/8/2011 4:53 AM, Regan Heath wrote: On Fri, 08 Jul 2011 10:49:08 +0100, Walter Bright wrote: On 7

Re: toStringz or not toStringz

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 09:54:15 -0400, Regan Heath wrote: On Fri, 08 Jul 2011 18:59:47 +0100, Walter Bright wrote: On 7/8/2011 4:53 AM, Regan Heath wrote: On Fri, 08 Jul 2011 10:49:08 +0100, Walter Bright wrote: On 7/8/2011 2:26 AM, Regan Heath wrote: Why can't we have the compiler c

Re: toStringz or not toStringz

2011-07-12 Thread Regan Heath
On Fri, 08 Jul 2011 18:59:47 +0100, Walter Bright wrote: On 7/8/2011 4:53 AM, Regan Heath wrote: On Fri, 08 Jul 2011 10:49:08 +0100, Walter Bright wrote: On 7/8/2011 2:26 AM, Regan Heath wrote: Why can't we have the compiler call it automatically whenever we pass a string, or char[]

Re: toStringz or not toStringz

2011-07-08 Thread Walter Bright
On 7/8/2011 4:53 AM, Regan Heath wrote: On Fri, 08 Jul 2011 10:49:08 +0100, Walter Bright wrote: On 7/8/2011 2:26 AM, Regan Heath wrote: Why can't we have the compiler call it automatically whenever we pass a string, or char[] to an extern "C" function, where the parameter is defined as char*

Re: [OT] Re: toStringz or not toStringz

2011-07-08 Thread Jonathan M Davis
On 2011-07-08 07:03, SimonM wrote: > This is kind of off-topic, and I don't know if it's just me, but I've > barely been able to use toStringz() where it's supposed to be useful: > > I tried using it with a C function whose parameters are not > const(char)*, but just char*, but because it returns

Re: [OT] Re: toStringz or not toStringz

2011-07-08 Thread Mike Parker
On 7/8/2011 11:03 PM, SimonM wrote: This is kind of off-topic, and I don't know if it's just me, but I've barely been able to use toStringz() where it's supposed to be useful: I tried using it with a C function whose parameters are not const(char)*, but just char*, but because it returns immutab

[OT] Re: toStringz or not toStringz

2011-07-08 Thread SimonM
This is kind of off-topic, and I don't know if it's just me, but I've barely been able to use toStringz() where it's supposed to be useful: I tried using it with a C function whose parameters are not const(char)*, but just char*, but because it returns immutable(char)'s I had to write my own o

Re: toStringz or not toStringz

2011-07-08 Thread Steven Schveighoffer
On Fri, 08 Jul 2011 07:53:20 -0400, Regan Heath wrote: On Fri, 08 Jul 2011 10:49:08 +0100, Walter Bright wrote: On 7/8/2011 2:26 AM, Regan Heath wrote: Why can't we have the compiler call it automatically whenever we pass a string, or char[] to an extern "C" function, where the param

Re: toStringz or not toStringz

2011-07-08 Thread Regan Heath
On Fri, 08 Jul 2011 10:49:08 +0100, Walter Bright wrote: On 7/8/2011 2:26 AM, Regan Heath wrote: Why can't we have the compiler call it automatically whenever we pass a string, or char[] to an extern "C" function, where the parameter is defined as char*? Because char* in C does not nece

Re: toStringz or not toStringz

2011-07-08 Thread Walter Bright
On 7/8/2011 2:26 AM, Regan Heath wrote: Why can't we have the compiler call it automatically whenever we pass a string, or char[] to an extern "C" function, where the parameter is defined as char*? Because char* in C does not necessarily mean "zero terminated string".

toStringz or not toStringz

2011-07-08 Thread Regan Heath
Sorry if this has been asked/answered before but I've been out of the loop for a while.. I was just thinking about the recent discussion on renaming toStringz and I wondered why we need to explicitly call it at all. Why can't we have the compiler call it automatically whenever we pass a st