D - a~=b VS a=a~b
- Keir (18/18) Apr 07 2003 given char[] a;
-
Carlos Santander B.
(44/44)
Apr 07 2003
"Keir"
escribiσ en el mensaje - Keir (66/66) Apr 08 2003 although, that doesn't answer why ~= works and =x~ doesn't... its entire...
-
Carlos Santander B.
(25/25)
Apr 08 2003
"Keir"
escribiσ en el mensaje - Ilya Minkov (2/9) Apr 09 2003 IIRC it was a guard against some common-made mistake.
- Walter (5/23) May 23 2003 able
- Keir (5/5) May 27 2003 is there an appropriate way to append characters to the end of a string?
- C. Sauls (12/13) May 30 2003 I've been using sequences like:
- Ilya Minkov (7/11) May 30 2003 Not without assigment, although the general idea is right.
- Ilya Minkov (6/8) May 28 2003 I believe this notation is also inconsistent - as it suggests 2 things b...
given char[] a; the line a~=args[0][j]; compiles (and works) just fine. But a=a~args[0][j]; does not and gives the message incompatible types for ((a) ~ (cast(int)(args[0][j]))): 'char[]' and 'int' are these two lines not functionally identical? Along a similar vein, I've noticed that given... char x; char[] a; char[] b; trying to do something like b=b~x; or b=b~a[i]; gives the same issue with the non-explicit cast to int. I haven't been able to get around it.
Apr 07 2003
"Keir" <keir verizon.net> escribiσ en el mensaje news:b6ssmk$k7r$1 digitaldaemon.com... | given char[] a; | | the line | a~=args[0][j]; | compiles (and works) just fine. But | a=a~args[0][j]; | does not and gives the message | incompatible types for ((a) ~ (cast(int)(args[0][j]))): 'char[]' and 'int' | | are these two lines not functionally identical? | | Along a similar vein, I've noticed that given... | char x; | char[] a; | char[] b; | | trying to do something like | | b=b~x; | | or | | b=b~a[i]; | | gives the same issue with the non-explicit cast to int. I haven't been able | to get around it. | | It's because int and char are basically the same. It's "one of those", like trying this: void foo(char x) { ... } void foo(char[] x) {...} ... foo('a'); Just doesn't compile. You have to explicitly cast. Carlos Santander --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.467 / Virus Database: 266 - Release Date: 2003-04-01
Apr 07 2003
although, that doesn't answer why ~= works and =x~ doesn't... its entirely possible that I'm casting incorrectly... I've tried, so far, ... b=b~x b=b~(char)x; b=b~(char[])x; b=b~cast(char)x; and b=b~cast(char[])x; so far, none of these have worked. the error from the compiler insists that it should be cast as an (int)... any idea's on how to override this? or what I'm doing incorrectly? "Carlos Santander B." <carlos8294 msn.com> wrote in message It's because int and char are basically the same. It's "one of those", like trying this: void foo(char x) { ... } void foo(char[] x) {...} ... foo('a'); Just doesn't compile. You have to explicitly cast. "Carlos Santander B." <carlos8294 msn.com> wrote in message news:b6sstb$kfa$1 digitaldaemon.com... "Keir" <keir verizon.net> escribiσ en el mensaje news:b6ssmk$k7r$1 digitaldaemon.com... | given char[] a; | | the line | a~=args[0][j]; | compiles (and works) just fine. But | a=a~args[0][j]; | does not and gives the message | incompatible types for ((a) ~ (cast(int)(args[0][j]))): 'char[]' and 'int' | | are these two lines not functionally identical? | | Along a similar vein, I've noticed that given... | char x; | char[] a; | char[] b; | | trying to do something like | | b=b~x; | | or | | b=b~a[i]; | | gives the same issue with the non-explicit cast to int. I haven't been able | to get around it. | | It's because int and char are basically the same. It's "one of those", like trying this: void foo(char x) { ... } void foo(char[] x) {...} ... foo('a'); Just doesn't compile. You have to explicitly cast. ------------------------- Carlos Santander --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.467 / Virus Database: 266 - Release Date: 2003-04-01
Apr 08 2003
"Keir" <keir verizon.net> escribiσ en el mensaje news:b6v61u$29m6$1 digitaldaemon.com... | although, that doesn't answer why ~= works and =x~ doesn't... its entirely | possible that I'm casting incorrectly... | | I've tried, so far, ... | b=b~x | b=b~(char)x; | b=b~(char[])x; | b=b~cast(char)x; | and | b=b~cast(char[])x; | | so far, none of these have worked. the error from the compiler insists that | it should be cast as an (int)... any idea's on how to override this? or what | I'm doing incorrectly? I know it doesn't answer it. I was just pointing a case. Carlos Santander --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.467 / Virus Database: 266 - Release Date: 2003-04-01
Apr 08 2003
Carlos Santander B. wrote:| so far, none of these have worked. the error from the compiler insists that | it should be cast as an (int)... any idea's on how to override this? or what | I'm doing incorrectly? I know it doesn't answer it. I was just pointing a case.IIRC it was a guard against some common-made mistake.
Apr 09 2003
"Keir" <keir verizon.net> wrote in message news:b6ssmk$k7r$1 digitaldaemon.com...given char[] a; the line a~=args[0][j]; compiles (and works) just fine. But a=a~args[0][j]; does not and gives the message incompatible types for ((a) ~ (cast(int)(args[0][j]))): 'char[]' and 'int' are these two lines not functionally identical? Along a similar vein, I've noticed that given... char x; char[] a; char[] b; trying to do something like b=b~x; or b=b~a[i]; gives the same issue with the non-explicit cast to int. I haven't beenableto get around it.I'm a bit nervous about making (char[] ~ char) work, as it could be a common source of bugs.
May 23 2003
is there an appropriate way to append characters to the end of a string? "Walter" <walter digitalmars.com> wrote in message news:bampoh$10mn$1 digitaldaemon.com... I'm a bit nervous about making (char[] ~ char) work, as it could be a common source of bugs.
May 27 2003
is there an appropriate way to append characters to the end of a string?I've been using sequences like: uint uibuf; char c; char[] str; . . . uibuf = str.length; str.length = str.length + 1; str[uibuf] = c; But shouldn't we be able to do something like: str ~ [c]; I think we should. - C. Sauls
May 30 2003
C. Sauls wrote:--- 8< ---(unappropriate kludge)--- >8 ---is there an appropriate way to append characters to the end of a string?But shouldn't we be able to do something like: str ~ [c]; I think we should.Not without assigment, although the general idea is right. Currently, i believe "str ~= c;" works. Surprise surprise. :/ The syntax is inconsistent. At least it was listed in Pavel's trick chest. -i.
May 30 2003
In article <bampoh$10mn$1 digitaldaemon.com>, Walter says...I'm a bit nervous about making (char[] ~ char) work, as it could be a common source of bugs.I believe this notation is also inconsistent - as it suggests 2 things being at the same level of abstraction when they aren't. And thus is a perfect source of confusion. When a single character (/value) is to be appended to an array, it has to be inclosed into an array literal syntax! -i.
May 28 2003