digitalmars.D.learn - aa bug?
- Saaa (11/11) Jul 28 2009 struct S
- Ary Borenszweig (10/23) Jul 28 2009 But you never inserted anything in aa["test"].
- Saaa (5/14) Jul 28 2009 erm, ok
- Jarrett Billingsley (4/22) Jul 28 2009 It won't happen. The behavior you want *used* to be the AA behavior
- Saaa (4/4) Jul 28 2009 It won't happen. The behavior you want *used* to be the AA behavior
- bearophile (10/21) Jul 28 2009 Try:
- Saaa (4/14) Jul 28 2009 struct literals .. need to remember all D's features :)
struct S
{
int i;
}
S[char[]] aa;
void main() {
aa["test"].i = 10;
}
Error: ArrayBoundsError
D1.046
looks like a bug to me or can't structs be aa's?
Jul 28 2009
Saaa escribió:
struct S
{
int i;
}
S[char[]] aa;
void main() {
aa["test"].i = 10;
}
Error: ArrayBoundsError
D1.046
looks like a bug to me or can't structs be aa's?
But you never inserted anything in aa["test"].
You must do:
S s;
aa["test"] = s;
aa["test"].i = 10;
or:
S s;
s.i = 10;
aa["test"] = s;
Jul 28 2009
But you never inserted anything in aa["test"]. You must do: S s; aa["test"] = s; aa["test"].i = 10; or: S s; s.i = 10; aa["test"] = s;erm, ok Thanks So no creation on use :) Personally I find the declation step clutter in the first case. Maybe promote the bug to a request?
Jul 28 2009
On Tue, Jul 28, 2009 at 6:09 PM, Saaa<empty needmail.com> wrote:It won't happen. The behavior you want *used* to be the AA behavior but was changed after several years and much complaining. It's not going back.But you never inserted anything in aa["test"]. You must do: S s; aa["test"] =3D s; aa["test"].i =3D 10; or: S s; s.i =3D 10; aa["test"] =3D s;erm, ok Thanks So no creation on use :) Personally I find the declation step clutter in the first case. Maybe promote the bug =A0to a request?
Jul 28 2009
It won't happen. The behavior you want *used* to be the AA behavior but was changed after several years and much complaining. It's not going back. Ah history :D
Jul 28 2009
Saaa:
struct S
{
int i;
}
S[char[]] aa;
void main() {
aa["test"].i = 10;
}
Error: ArrayBoundsError
D1.046
Try:
struct S { int i; }
S[char[]] aa;
void main() {
aa["test"] = S(10);
}
In theory a Sufficiently Smart Compiler is able to optimize that code well.
Bye,
bearophile
Jul 28 2009
struct literals .. need to remember all D's features :)
D1.046 seems SS
aa["test"]=S();
works fine as well
Try:
struct S { int i; }
S[char[]] aa;
void main() {
aa["test"] = S(10);
}
In theory a Sufficiently Smart Compiler is able to optimize that code
well.
Bye,
bearophile
Jul 28 2009









"Saaa" <empty needmail.com> 