Re: Clear big AAs

2011-06-12 Thread useo
> useo: > > Is there anything I forgot to consider? > If the key and values are primitive values or structs of primitive values then you may try another AA implementation that doesn't use the GC. > Bye, > bearophile I tried some different implementations and I also reduced the size of my arrays wi

Re: Object

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 22:37, Jonathan M Davis wrote: > On 2011-06-12 22:25, Lloyd Dupont wrote: > > I have problem with "Object" > > > > for example this doesn't compile: > > === > > Object o; > > o = ""; > > === > > with error: cannot implicitly convert expression ("") of type string to > > object.Object

Re: Object

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 22:25, Lloyd Dupont wrote: > I have problem with "Object" > > for example this doesn't compile: > === > Object o; > o = ""; > === > with error: cannot implicitly convert expression ("") of type string to > object.Object Object is the base class of all classes. Nothing which is not a

Object

2011-06-12 Thread Lloyd Dupont
I have problem with "Object" for example this doesn't compile: === Object o; o = ""; === with error: cannot implicitly convert expression ("") of type string to object.Object or this also failed to compile: === class Foo { public: Object foo, bar, snafu; override const bool opEquals(Obj

Re: string manipulation performance

2011-06-12 Thread Lloyd Dupont
Thanks Steven, that was very informative! "Steven Schveighoffer" wrote in message news:op.vwzrwdmteav7ka@localhost.localdomain... On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont wrote: But... string being immutable I don't see the point of allocating some space for one.. Am I missing som

Re: string manipulation performance

2011-06-12 Thread Steven Schveighoffer
On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont wrote: But... string being immutable I don't see the point of allocating some space for one.. Am I missing something? Reserving space for appending does not make that space immutable, yet. As far as the runtime is concerned, that space is

Re: string manipulation performance

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 18:02, Lloyd Dupont wrote: > But... string being immutable I don't see the point of allocating some > space for one.. > Am I missing something? Just because it's immutable doesn't mean that it doesn't need to exist at runtime. All immutable means is that you can't change it. It coul

Re: string manipulation performance

2011-06-12 Thread Lloyd Dupont
Thanks! "Jonathan M Davis" wrote in message news:mailman.851.1307909610.14074.digitalmars-d- Also, std.string.repeat has been scheduled for deprecation. You should use std.array.replicate instead. It does the same thing but for all arrays instead of just strings. - Jonathan M Davis

Re: enum sstring problem

2011-06-12 Thread Andrej Mitrovic
I've got 2.053 and it works for me.

Re: string manipulation performance

2011-06-12 Thread Lloyd Dupont
But... string being immutable I don't see the point of allocating some space for one.. Am I missing something? "Steven Schveighoffer" wrote in message news:op.vwy503w4eav7ka@localhost.localdomain... On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont wrote: I have a method like that: === pub

Re: format()

2011-06-12 Thread Lloyd Dupont
yep, the example is simple because it is an example! Thanks for your suggestion! :) "Jonathan M Davis" wrote in message news:mailman.850.1307909499.14074.digitalmars-d-le...@puremagic.com... On 2011-06-12 10:30, David Nadlinger wrote: On 6/12/11 6:37 PM, Lloyd Dupont wrote: > mm... ok. > but

Re: enum sstring problem

2011-06-12 Thread Lloyd Dupont
do you have DMD 2.053 on Windows? Your code fail for me with: main.d(10): Error: Integer constant expression expected instead of "hello" main.d(11): Error: Integer constant expression expected instead of "betty" main.d(10): Error: Integer constant expression expected instead of "hello" main.d

Re: enum sstring problem

2011-06-12 Thread Timon Gehr
Lloyd Dupont wrote: > I'm using 2.053 > this compile fine: > > enum : string > { > A = "hello", > B = "betty", > } > > > this doesn't! > > enum AA : string > { > A = "hello", > B = "betty", > } > > > Am I missing something? Named enum can't be typed? known bug?

Re: format()

2011-06-12 Thread jdrewsen
Den 12-06-2011 18:37, Lloyd Dupont skrev: mm... ok. but why the line below doesn't compile? mixin(format("class %s {}", "A")); Because the mixin is evaluated at compile time. This means that format(...) is evaluated at compile time which afaik is not supported. It may be supported in the fu

Re: about attribute... (trying to implement a "DataContractSerializer" functionality)

2011-06-12 Thread jdrewsen
Den 12-06-2011 15:43, Lloyd Dupont skrev: From the book I was under the impression that there could be user defined attribute. I wonder if this has been implemented? My problem: I try to implement a simplistic "DataContractSerializer" (as in http://msdn.microsoft.com/en-us/library/SYSTEM.RUNTIM

Re: string manipulation performance

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 11:08, Steven Schveighoffer wrote: > On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont > > wrote: > > I have a method like that: > > === > > public string repeat(string s, int num) > > { > > > > string result = s; > > for (int i=1; i > > > result ~= s; > >

Re: format()

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 10:30, David Nadlinger wrote: > On 6/12/11 6:37 PM, Lloyd Dupont wrote: > > mm... ok. > > but why the line below doesn't compile? > > > > mixin(format("class %s {}", "A")); > > Because format presumably can't be interpreted at compile time (yet) – > not all functions are necessarily

Re: + operators

2011-06-12 Thread Don
Jonathan M Davis wrote: On 2011-06-12 02:37, bearophile wrote: Jonathan M Davis: Certainly, once range propagation has been fully implemented, this particular will work without needing any casts, but as soon as the compiler doesn't know what the values of x and y are, I believe that it would st

Re: string manipulation performance

2011-06-12 Thread Steven Schveighoffer
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont wrote: I have a method like that: === public string repeat(string s, int num) { string result = s; for (int i=1; i The runtime tries its best to avoid allocating a new string on each append. Please read the manual on appending, and

Re: format()

2011-06-12 Thread David Nadlinger
On 6/12/11 6:37 PM, Lloyd Dupont wrote: mm... ok. but why the line below doesn't compile? mixin(format("class %s {}", "A")); Because format presumably can't be interpreted at compile time (yet) – not all functions are necessarily CTFEable. David

string manipulation performance

2011-06-12 Thread Lloyd Dupont
I have a method like that: === public string repeat(string s, int num) { string result = s; for (int i=1; i

enum sstring problem

2011-06-12 Thread Lloyd Dupont
I'm using 2.053 this compile fine: enum : string { A = "hello", B = "betty", } this doesn't! enum AA : string { A = "hello", B = "betty", } Am I missing something? Named enum can't be typed? known bug?

Re: format()

2011-06-12 Thread Lloyd Dupont
mm... ok. but why the line below doesn't compile? mixin(format("class %s {}", "A")); "bearophile" wrote in message news:it2pf5$1qh6$1...@digitalmars.com... Apparently std.string.format() is not implemented / does not compile! :( This works for me, DMD 2.053:

Re: format()

2011-06-12 Thread bearophile
Lloyd Dupon: > Apparently std.string.format() is not implemented / does not compile! :( This works for me, DMD 2.053: import std.stdio, std.string; void main() { int x = 10; auto s = format("%d", 10); writeln(">", s, "<"); } Bye, bearophile

format()

2011-06-12 Thread Lloyd Dupont
Apparently std.string.format() is not implemented / does not compile! :( Is there any sort of replacement? Something which works like writefln() but output a string!

about attribute... (trying to implement a "DataContractSerializer" functionality)

2011-06-12 Thread Lloyd Dupont
From the book I was under the impression that there could be user defined attribute. I wonder if this has been implemented? My problem: I try to implement a simplistic "DataContractSerializer" (as in http://msdn.microsoft.com/en-us/library/SYSTEM.RUNTIME.SERIALIZATION.DATACONTRACTSERIALIZER(v=vs

Re: + operators

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 02:37, bearophile wrote: > Jonathan M Davis: > > Certainly, once range propagation has been fully implemented, this > > particular will work without needing any casts, but as soon as the > > compiler doesn't know what the values of x and y are, I believe that it > > would still end up

Re: + operators

2011-06-12 Thread bearophile
Jonathan M Davis: > Certainly, once range propagation has been fully implemented, this particular > will work without needing any casts, but as soon as the compiler doesn't know > what the values of x and y are, I believe that it would still end up > complaining. I am not sure D range propagat

Re: + operators

2011-06-12 Thread bearophile
Jonathan M Davis: > That would depend entirely on the optimizer. You have to take a look at the asm produced by the compiler to be sure what its optimizations have done. Bye, bearophile

Thousands separators

2011-06-12 Thread bearophile
Do you know if in Phobos there is already a way to format a number with thousands separators (a point, comma o underscore)? Bye and thank you, bearophile