I currently almost always use const(char)[] for function parameters to
make it possible to also pass char[] strings to the function.
Are there any disadvantages like optimization issues?
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]
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?
On Tue, Jul 28, 2009 at 6:09 PM, Saaaem...@needmail.com wrote:
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
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
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
So scope for class references guarantees that the destructor is called
upon leaving the scope (why isn't this done automatically?).
But what if scope is used with basic types like scope int x;
What's the effect?
Is there such stuff available in D website? Or the only choice to quick check
what features are supported by D2 also supported by D1 is to go through the
spec?
Thanks in advance.
Regards,
Sam
On Tue, Jul 28, 2009 at 10:46 PM, Trass3rmrmoc...@gmx.de wrote:
So scope for class references guarantees that the destructor is called upon
leaving the scope (why isn't this done automatically?).
Why isn't what done automatically?
But what if scope is used with basic types like scope int x;
On Tue, Jul 28, 2009 at 11:11 PM, Sam Husamhudotsa...@gmail.com wrote:
Is there such stuff available in D website? Or the only choice to quick
check what features are supported by D2 also supported by D1 is to go through
the spec?
Thanks in advance.
Regards,
Sam
Jarrett Billingsley Wrote:
http://www.digitalmars.com/d/2.0/features2.html
Thank you so much.So silly a question :P
11 matches
Mail list logo