D - parameter decorator for zero-terminated strings
- Matthew Wilson (6/6) Sep 17 2003 I'd really like a parameter decorator that caused either automatic
- Philippe Mori (5/11) Sep 17 2003 explicit
- Matthew Wilson (11/26) Sep 17 2003 Does that make a zero-terminated copy, or modify the array itself?
- J Anderson (2/29) Sep 17 2003 And then you could have d_str() to convert back (just kidding).
I'd really like a parameter decorator that caused either automatic conversion of a character (char or wchar) array to a zero-terminated string, a la toStringz, or, preferably, requires a cast (thus causing the programmer to be mindful of the need to null-terminate). In fact, I'd quite like any function taking char/wchar* requires an explicit cast from char/wchar[]. Is there a reason why this is not required now?
Sep 17 2003
I'd really like a parameter decorator that caused either automatic conversion of a character (char or wchar) array to a zero-terminatedstring,a la toStringz, or, preferably, requires a cast (thus causing theprogrammerto be mindful of the need to null-terminate). In fact, I'd quite like any function taking char/wchar* requires anexplicitcast from char/wchar[]. Is there a reason why this is not required now?I would prefer a member function c_str() as in C++ STL. No ugly cast, no unwanted conversions...
Sep 17 2003
Does that make a zero-terminated copy, or modify the array itself? Either way I don't really like it, since it is limiting. There are cases when the programmer will know that the array is already zero-terminated, so calling a modifying (or copying and modifying) function will be inefficient. There will also be cases where the programmer will know that a zero-termination is not required, and to do one would be inefficient. I want a cast, and the uglier the better. This will be used in connecting to legacy C functions, and in that case I think it's a good thing that it's highly visible (and ugly, if you will). "Philippe Mori" <philippe_mori hotmail.com> wrote in message news:bk9oeq$2565$1 digitaldaemon.com...I'd really like a parameter decorator that caused either automatic conversion of a character (char or wchar) array to a zero-terminatedstring,a la toStringz, or, preferably, requires a cast (thus causing theprogrammerto be mindful of the need to null-terminate). In fact, I'd quite like any function taking char/wchar* requires anexplicitcast from char/wchar[]. Is there a reason why this is not required now?I would prefer a member function c_str() as in C++ STL. No ugly cast, no unwanted conversions...
Sep 17 2003
Philippe Mori wrote:And then you could have d_str() to convert back (just kidding).I'd really like a parameter decorator that caused either automatic conversion of a character (char or wchar) array to a zero-terminatedstring,a la toStringz, or, preferably, requires a cast (thus causing theprogrammerto be mindful of the need to null-terminate). In fact, I'd quite like any function taking char/wchar* requires anexplicitcast from char/wchar[]. Is there a reason why this is not required now?I would prefer a member function c_str() as in C++ STL. No ugly cast, no unwanted conversions...
Sep 17 2003