D - A bug, feature or misunderstanding?
- Gennadi Pais (10/10) Aug 05 2003 Hi All,
- Matthew Wilson (3/13) Aug 05 2003 Use %.*s for the string format specifier
- Gennadi Pais (2/21) Aug 05 2003
- Matthew Wilson (5/30) Aug 05 2003 Sorry, I don't understand. In your example you said you done "%s", where...
- Gennadi Pais (13/46) Aug 05 2003 Please pay attention to the next cut from the D's spec (Arrays section):
- Matthew Wilson (17/67) Aug 05 2003 I may be missing something here - possible - but you seem to be
- Matthew Wilson (7/80) Aug 05 2003 Correction, the two examples I meant were
- Gennadi Pais (8/100) Aug 05 2003 Dear All,
- Paul Runde (12/28) Aug 05 2003 From html/d/arrays.html
- Mike Wynn (10/20) Aug 05 2003 ^^^ see this line
- Walter (1/1) Sep 12 2003 Thanks for pointing this out. I've corrected the spec.
Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
Use %.*s for the string format specifier "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
That's the way I implemented it, but what about the spec? In article <bgnsh5$pk3$1 digitaldaemon.com>, Matthew Wilson says...Use %.*s for the string format specifier "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
Sorry, I don't understand. In your example you said you done "%s", whereas I'm saying you must use "%.*s". If indeed you used "%.*s" then it's out of my jurisdiction, I'm afraid. ;) "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnte9$qg8$1 digitaldaemon.com...That's the way I implemented it, but what about the spec? In article <bgnsh5$pk3$1 digitaldaemon.com>, Matthew Wilson says...Use %.*s for the string format specifier "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
Please pay attention to the next cut from the D's spec (Arrays section): ______________________________ There are two ways to use printf() with D strings. The first is to add a terminating 0, and cast the result to a char*: str.append(0); printf("the string is '%s'\n", (char *)str); The second way is to use the precision specifier. The way D arrays are laid out, the length comes first, so the following works: printf("the string is '%.*s'\n", str); ______________________________ I just want to say that the first described above way is not compiled and failed with an error (see my first message). In article <bgo3ds$101p$1 digitaldaemon.com>, Matthew Wilson says...Sorry, I don't understand. In your example you said you done "%s", whereas I'm saying you must use "%.*s". If indeed you used "%.*s" then it's out of my jurisdiction, I'm afraid. ;) "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnte9$qg8$1 digitaldaemon.com...That's the way I implemented it, but what about the spec? In article <bgnsh5$pk3$1 digitaldaemon.com>, Matthew Wilson says...Use %.*s for the string format specifier "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
I may be missing something here - possible - but you seem to be contradicting yourself. Your first example was char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); Now in this you do neither of printf ("str is: %s\n", (char*)str); or printf ("str is: %.*s\n", (char*)str); Surely this is clear? "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgoe7f$1b2c$1 digitaldaemon.com...Please pay attention to the next cut from the D's spec (Arrays section): ______________________________ There are two ways to use printf() with D strings. The first is to add a terminating 0, and cast the result to a char*: str.append(0); printf("the string is '%s'\n", (char *)str); The second way is to use the precision specifier. The way D arrays arelaid out,the length comes first, so the following works: printf("the string is '%.*s'\n", str); ______________________________ I just want to say that the first described above way is not compiled andfailedwith an error (see my first message). In article <bgo3ds$101p$1 digitaldaemon.com>, Matthew Wilson says...whereasSorry, I don't understand. In your example you said you done "%s",ofI'm saying you must use "%.*s". If indeed you used "%.*s" then it's outmy jurisdiction, I'm afraid. ;) "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnte9$qg8$1 digitaldaemon.com...That's the way I implemented it, but what about the spec? In article <bgnsh5$pk3$1 digitaldaemon.com>, Matthew Wilson says...Use %.*s for the string format specifier "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
Correction, the two examples I meant were printf ("str is: %s\n", (char*)str); or printf ("str is: %.*s\n", str); "Matthew Wilson" <matthew stlsoft.org> wrote in message news:bgp97g$272e$1 digitaldaemon.com...I may be missing something here - possible - but you seem to be contradicting yourself. Your first example was char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); Now in this you do neither of printf ("str is: %s\n", (char*)str); or printf ("str is: %.*s\n", (char*)str); Surely this is clear? "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgoe7f$1b2c$1 digitaldaemon.com...andPlease pay attention to the next cut from the D's spec (Arrays section): ______________________________ There are two ways to use printf() with D strings. The first is to add a terminating 0, and cast the result to a char*: str.append(0); printf("the string is '%s'\n", (char *)str); The second way is to use the precision specifier. The way D arrays arelaid out,the length comes first, so the following works: printf("the string is '%.*s'\n", str); ______________________________ I just want to say that the first described above way is not compiledfailedwith an error (see my first message). In article <bgo3ds$101p$1 digitaldaemon.com>, Matthew Wilson says...whereasSorry, I don't understand. In your example you said you done "%s",ofI'm saying you must use "%.*s". If indeed you used "%.*s" then it's outmy jurisdiction, I'm afraid. ;) "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnte9$qg8$1 digitaldaemon.com...That's the way I implemented it, but what about the spec? In article <bgnsh5$pk3$1 digitaldaemon.com>, Matthew Wilson says...Use %.*s for the string format specifier "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
Dear All, thank for the explanation how can I print a string out, but if you will pay attention I didn't ask about how to (I've found some different ways), but the issue was the compilation error because of lack of the array's <append> method. I think the clear and right spec is exactly what the new language need. So I want to ask somebody who has permission to edit D's documentation to fix that over there. In article <bgpb2f$28tu$1 digitaldaemon.com>, Matthew Wilson says...Correction, the two examples I meant were printf ("str is: %s\n", (char*)str); or printf ("str is: %.*s\n", str); "Matthew Wilson" <matthew stlsoft.org> wrote in message news:bgp97g$272e$1 digitaldaemon.com...I may be missing something here - possible - but you seem to be contradicting yourself. Your first example was char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); Now in this you do neither of printf ("str is: %s\n", (char*)str); or printf ("str is: %.*s\n", (char*)str); Surely this is clear? "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgoe7f$1b2c$1 digitaldaemon.com...andPlease pay attention to the next cut from the D's spec (Arrays section): ______________________________ There are two ways to use printf() with D strings. The first is to add a terminating 0, and cast the result to a char*: str.append(0); printf("the string is '%s'\n", (char *)str); The second way is to use the precision specifier. The way D arrays arelaid out,the length comes first, so the following works: printf("the string is '%.*s'\n", str); ______________________________ I just want to say that the first described above way is not compiledfailedwith an error (see my first message). In article <bgo3ds$101p$1 digitaldaemon.com>, Matthew Wilson says...whereasSorry, I don't understand. In your example you said you done "%s",ofI'm saying you must use "%.*s". If indeed you used "%.*s" then it's outmy jurisdiction, I'm afraid. ;) "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnte9$qg8$1 digitaldaemon.com...That's the way I implemented it, but what about the spec? In article <bgnsh5$pk3$1 digitaldaemon.com>, Matthew Wilson says...Use %.*s for the string format specifier "Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.
Aug 05 2003
Gennadi Pais wrote:Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0); printf ("str is: %s\n", str); I received compiler error: .. undefined identifier append Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.From html/d/arrays.html " Since strings, however, are not 0 terminated in D, when transfering a pointer to a string to C, add a terminating 0: str.append(0); " However, append is not listed as an array property. Try this: import string; char[] str = "blah-blah"; printf ("str is: %s\n", toStringz(str)); toStringz appends the terminator. Paul
Aug 05 2003
"Gennadi Pais" <Gennadi_member pathlink.com> wrote in message news:bgnqjm$nsb$1 digitaldaemon.com...Hi All, during my first trying of the D language in the code: char[] str = "blah-blah"; str.append(0);^^^ see this lineprintf ("str is: %s\n", str); I received compiler error: .. undefined identifier append^^^ this error is because char[] does not have an append function.Compiler is: Digital Mars D Compiler Beta v0.68 The tested code is from the D spec. Thanks.try char[] str = "blah-blah"; printf ("str is: %.*s\n", str); "%.*s" is the D string format spec. if you want to append to a string use operator ~ str = str ~ "\0"; or str = str ~ \0; /// note no ' ' as you would in C.
Aug 05 2003
Thanks for pointing this out. I've corrected the spec.
Sep 12 2003