D - [Bug?] T[] ~= T vs. T[] ~ T
- Stewart Gordon (35/35) Mar 29 2004 Using DMD 0.81, Windows 98SE.
- J Anderson (5/36) Mar 29 2004 Yes it is. You can't append a character (or whatever) on to an array.
- Stewart Gordon (8/25) Mar 29 2004 What has that to do with the fact it works with ~= ?
- J Anderson (6/9) Mar 29 2004 It's not a bug its by design. However it would be nice to have the
- C (13/23) Mar 29 2004 Inconsitency is a bug to me,
- C (9/32) Mar 29 2004 Ugh, im suffering from not reading enough lately. ( Didnt read entire =
- Stewart Gordon (7/14) Apr 01 2004 OK, so what bit of the spec have you found that I haven't?
Using DMD 0.81, Windows 98SE.
It isn't clear from the spec which concatenation operations are actually
supposed to be supported.
Given a type T, there are four possibilities:
(a) T[] ~ T[]
(b) T[] ~ T
(c) T[] ~= T[]
(d) T[] ~= T
My experiments have shown that all but (b) work. For example, this
compiles:
----------
int main() {
char[] x = "abc";
x ~= x[1];
x ~= 'x';
return 0;
}
----------
but this doesn't:
----------
int main() {
char[] x = "abc";
char[] y = x ~ x[1] ~ 'x';
return 0;
}
----------
D:\My Documents\Programming\D\Tests\bugs\charcat.d(3): incompatible
types for ((x) ~ (cast(int)(x[1]))): 'char[]' and 'int'
Is this supposed to happen? It seems just plain inconsistent from where
I am, and I can't see any reason that this shouldn't be allowed.
Stewart.
--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Mar 29 2004
Stewart Gordon wrote:
Using DMD 0.81, Windows 98SE.
It isn't clear from the spec which concatenation operations are
actually supposed to be supported.
Given a type T, there are four possibilities:
(a) T[] ~ T[]
(b) T[] ~ T
(c) T[] ~= T[]
(d) T[] ~= T
My experiments have shown that all but (b) work. For example, this
compiles:
----------
int main() {
char[] x = "abc";
x ~= x[1];
x ~= 'x';
return 0;
}
----------
but this doesn't:
----------
int main() {
char[] x = "abc";
char[] y = x ~ x[1] ~ 'x';
return 0;
}
----------
D:\My Documents\Programming\D\Tests\bugs\charcat.d(3): incompatible
types for ((x) ~ (cast(int)(x[1]))): 'char[]' and 'int'
Is this supposed to happen? It seems just plain inconsistent from
where I am, and I can't see any reason that this shouldn't be allowed.
Stewart.
Yes it is. You can't append a character (or whatever) on to an array.
You must append an array on to an array.
--
-Anderson: http://badmama.com.au/~anderson/
Mar 29 2004
J Anderson wrote:Stewart Gordon wrote:<snip>Using DMD 0.81, Windows 98SE. It isn't clear from the spec which concatenation operations are actually supposed to be supported. Given a type T, there are four possibilities: (a) T[] ~ T[] (b) T[] ~ T (c) T[] ~= T[] (d) T[] ~= T My experiments have shown that all but (b) work.Yes it is. You can't append a character (or whatever) on to an array. You must append an array on to an array.What has that to do with the fact it works with ~= ? Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Mar 29 2004
Stewart Gordon wrote:J Anderson wrote: What has that to do with the fact it works with ~= ? Stewart.It's not a bug its by design. However it would be nice to have the ability to append an element on to an array like you suggest. The ~= works, but the ~x[1] in my opinion is a consistency problem but not a bug. -- -Anderson: http://badmama.com.au/~anderson/
Mar 29 2004
Inconsitency is a bug to me, And this still works int [] x; x ~=3D 3; but not this ? char [] x; x ~=3D 'Y'; C On Mon, 29 Mar 2004 22:34:21 +0800, J Anderson = <REMOVEanderson badmama.com.au> wrote:Stewart Gordon wrote:J Anderson wrote: What has that to do with the fact it works with ~=3D ? Stewart.It's not a bug its by design. However it would be nice to have the =ability to append an element on to an array like you suggest. The ~=3D==works, but the ~x[1] in my opinion is a consistency problem but not a =bug.-- = D Newsgroup.
Mar 29 2004
Ugh, im suffering from not reading enough lately. ( Didnt read entire = first post ). Just ignore me. C On Mon, 29 Mar 2004 11:33:59 -0800, C <dont respond.com> wrote:Inconsitency is a bug to me, And this still works int [] x; x ~=3D 3; but not this ? char [] x; x ~=3D 'Y'; C On Mon, 29 Mar 2004 22:34:21 +0800, J Anderson =<REMOVEanderson badmama.com.au> wrote:Stewart Gordon wrote:J Anderson wrote: What has that to do with the fact it works with ~=3D ? Stewart.It's not a bug its by design. However it would be nice to have the ==ability to append an element on to an array like you suggest. The ~=3D==works, but the ~x[1] in my opinion is a consistency problem but not a=-- = D Newsgroup.bug.
Mar 29 2004
J Anderson wrote:Stewart Gordon wrote:OK, so what bit of the spec have you found that I haven't? Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.J Anderson wrote: What has that to do with the fact it works with ~= ?It's not a bug its by design.
Apr 01 2004









C <dont respond.com> 