Re: Successively prepending to slices.

2014-04-10 Thread monarch_dodra
On Thursday, 10 April 2014 at 20:03:46 UTC, JR wrote: In my NewlineBufferThingy struct, I sometimes need to move a slice at an arbitrary point of an array to the very beginning of it, like a poor man's circular buffer. Just in case somebody is wondering, phobos has std.range.cycle for circula

Re: Successively prepending to slices.

2014-04-10 Thread dnspies
On Thursday, 10 April 2014 at 05:54:52 UTC, monarch_dodra wrote: On Wednesday, 9 April 2014 at 23:53:04 UTC, dnspies wrote: Does concatenation always create a new array? What if the type of the original is immutable (or even const)? In that case, wouldn't it be worthwhile to check first if rh

Re: Successively prepending to slices.

2014-04-10 Thread JR
It depends on your use-case, I think. How often will you be prepending? Will you be appending as well? On Thursday, 10 April 2014 at 16:10:04 UTC, Steven Schveighoffer wrote: Note, I create a deque class in dcollections which maintains 2 arrays, one for prepending (and is in reverse order), an

Re: Anyone have sucess converting MSVC 2010 COFF libs to OMF

2014-04-10 Thread Gary Willoughby
On Tuesday, 8 April 2014 at 17:23:14 UTC, Byron wrote: I have several libs compiled in vs2010 that I need to convert to omf. Try the coffimplib tool: http://forum.dlang.org/thread/dpaolp$1oek$1...@digitaldaemon.com

Re: Successively prepending to slices.

2014-04-10 Thread Steven Schveighoffer
On Wed, 09 Apr 2014 19:18:25 -0400, dnspies wrote: I know that D slices are set up so you can successively append to them and it only has to re-allocate infrequently, but what about with prepending? ie, does D have a way to handle int[] x; for(int i=0; i < 1000; i++) { x = [i] ~ x; }

Re: Design with appender: good or bad?

2014-04-10 Thread monarch_dodra
On Thursday, 10 April 2014 at 13:57:26 UTC, Chris wrote: The funny thing, though, is that after clearing buf writeln(data1[0]); still prints "World1". It only changes after I add a new item to buf. clear doesn't actually "clear" in the "wipe" sense of the word. It only means that the data is

Re: Design with appender: good or bad?

2014-04-10 Thread Chris
On Thursday, 10 April 2014 at 13:53:46 UTC, Chris wrote: On Thursday, 10 April 2014 at 10:47:08 UTC, Rene Zwanenburg wrote: On Thursday, 10 April 2014 at 10:16:43 UTC, Chris wrote: Ah, this one \me (= escaped me). Sorry I wasn't precise, I was wondering if it is in any way dangerous to have @

Re: Design with appender: good or bad?

2014-04-10 Thread Chris
On Thursday, 10 April 2014 at 13:47:22 UTC, monarch_dodra wrote: That said, it feels like you are using Appender like a container. Maybe "Array" is a better fit? It is not really a container in the sense that I add and remove items at random later in the program. The items are added in a loo

Re: Design with appender: good or bad?

2014-04-10 Thread Rene Zwanenburg
On Thursday, 10 April 2014 at 13:57:26 UTC, Chris wrote: The funny thing, though, is that after clearing buf writeln(data1[0]); still prints "World1". It only changes after I add a new item to buf. Correct. The memory has not been touched by clear(), it just sets it's internal used element

Re: Design with appender: good or bad?

2014-04-10 Thread Chris
On Thursday, 10 April 2014 at 14:16:02 UTC, Rene Zwanenburg wrote: On Thursday, 10 April 2014 at 13:57:26 UTC, Chris wrote: The funny thing, though, is that after clearing buf writeln(data1[0]); still prints "World1". It only changes after I add a new item to buf. Correct. The memory has n

Re: Anyone have sucess converting MSVC 2010 COFF libs to OMF

2014-04-10 Thread Byron
On Thu, 10 Apr 2014 14:10:37 +1000, Daniel Murphy wrote: > "Byron" wrote in message news:li1ba2$5lc$1...@digitalmars.com... > >> So does anyone have a fool prof way of converting coff to omf libs. I >> feel like this use to be easy.. > > In general, this won't work. The only thing that is str

Re: Design with appender: good or bad?

2014-04-10 Thread Chris
On Thursday, 10 April 2014 at 10:47:08 UTC, Rene Zwanenburg wrote: On Thursday, 10 April 2014 at 10:16:43 UTC, Chris wrote: Ah, this one \me (= escaped me). Sorry I wasn't precise, I was wondering if it is in any way dangerous to have @property string[] items() { return buf.data; } instead o

Re: Design with appender: good or bad?

2014-04-10 Thread monarch_dodra
On Thursday, 10 April 2014 at 13:29:39 UTC, Chris wrote: Thanks. But the question was not about how to print it to console, but whether there are any hidden dangers in using Appender in this way, like the one Rene mentioned. AFAIK, no. In fact, arguably, it's saf*er*, since an appender has a

Re: Design with appender: good or bad?

2014-04-10 Thread Chris
On Thursday, 10 April 2014 at 11:40:46 UTC, monarch_dodra wrote: On Thursday, 10 April 2014 at 10:16:43 UTC, Chris wrote: because the two are not the same. When you print MyStruct to console you get the address of appender buf, whereas when you use string[] items you get the actual items. I'm o

Re: Anyone have sucess converting MSVC 2010 COFF libs to OMF

2014-04-10 Thread Ettienne Gilbert
On Tuesday, 8 April 2014 at 17:23:14 UTC, Byron wrote: I have several libs compiled in vs2010 that I need to convert to omf. With the same setup I have this linked in win64, just want to get win32. I have tried coff2omf but it fails with: coff2omf leveldb.lib COFF2OMF: Converting 'd:\proje

Re: GC being too eager?

2014-04-10 Thread Paulo Pinto
On Thursday, 10 April 2014 at 09:31:30 UTC, John Colvin wrote: On Thursday, 10 April 2014 at 09:24:51 UTC, Paulo Pinto wrote: In a toy project I am working on with D v2.065, I came to the following situation: Node path = solver.find (map, start, end); if (path !is null) { path.writeContents

Re: Why does filter return const?

2014-04-10 Thread monarch_dodra
On Thursday, 10 April 2014 at 10:30:19 UTC, Edwin van Leeuwen wrote: I'd like to filter a range and then change the filtered results, but FilterResult returns a const. Is there any (straightforward) way of doing what I want? I guess I could create duplicates, but I would like my changes also

Re: Why does filter return const?

2014-04-10 Thread bearophile
Edwin van Leeuwen: I'd like to filter a range and then change the filtered results, but FilterResult returns a const. Is there any (straightforward) way of doing what I want? I guess I could create duplicates, but I would like my changes also to be reflected in the original range. Mixing f

Re: Design with appender: good or bad?

2014-04-10 Thread monarch_dodra
On Thursday, 10 April 2014 at 10:16:43 UTC, Chris wrote: because the two are not the same. When you print MyStruct to console you get the address of appender buf, whereas when you use string[] items you get the actual items. I'm only wondereing if using appender is potentially dangerous and cou

Re: GC being too eager?

2014-04-10 Thread Paulo Pinto
On Thursday, 10 April 2014 at 09:31:30 UTC, John Colvin wrote: On Thursday, 10 April 2014 at 09:24:51 UTC, Paulo Pinto wrote: In a toy project I am working on with D v2.065, I came to the following situation: Node path = solver.find (map, start, end); if (path !is null) { path.writeContents

Re: GC being too eager?

2014-04-10 Thread Paulo Pinto
On Thursday, 10 April 2014 at 10:37:58 UTC, Rene Zwanenburg wrote: On Thursday, 10 April 2014 at 09:24:51 UTC, Paulo Pinto wrote: In a toy project I am working on with D v2.065, I came to the following situation: Node path = solver.find (map, start, end); if (path !is null) { path.writeCont

Re: Design with appender: good or bad?

2014-04-10 Thread Rene Zwanenburg
On Thursday, 10 April 2014 at 10:16:43 UTC, Chris wrote: Ah, this one \me (= escaped me). Sorry I wasn't precise, I was wondering if it is in any way dangerous to have @property string[] items() { return buf.data; } instead of: string[] items; // ... public addItem(string item) { items ~=

Re: GC being too eager?

2014-04-10 Thread Rene Zwanenburg
On Thursday, 10 April 2014 at 09:24:51 UTC, Paulo Pinto wrote: In a toy project I am working on with D v2.065, I came to the following situation: Node path = solver.find (map, start, end); if (path !is null) { path.writeContents(); <-- Access Violation } Apparently between the test and tr

Why does filter return const?

2014-04-10 Thread Edwin van Leeuwen
I'd like to filter a range and then change the filtered results, but FilterResult returns a const. Is there any (straightforward) way of doing what I want? I guess I could create duplicates, but I would like my changes also to be reflected in the original range. Cheers, Edwin

Re: Design with appender: good or bad?

2014-04-10 Thread Chris
On Thursday, 10 April 2014 at 10:00:16 UTC, John Colvin wrote: On Thursday, 10 April 2014 at 09:47:35 UTC, Chris wrote: Are there any drawbacks with this design, i.e. using buf.put() here (instead of a less efficient items ~= item;)? struct MyStruct { Appender!(string[]) buf; string name;

Re: Design with appender: good or bad?

2014-04-10 Thread John Colvin
On Thursday, 10 April 2014 at 09:47:35 UTC, Chris wrote: Are there any drawbacks with this design, i.e. using buf.put() here (instead of a less efficient items ~= item;)? struct MyStruct { Appender!(string[]) buf; string name; this(string name) { this.name = name; buf = appender!

Design with appender: good or bad?

2014-04-10 Thread Chris
Are there any drawbacks with this design, i.e. using buf.put() here (instead of a less efficient items ~= item;)? struct MyStruct { Appender!(string[]) buf; string name; this(string name) { this.name = name; buf = appender!(string[]); } public addItem(string item) { buf.p

Re: GC being too eager?

2014-04-10 Thread John Colvin
On Thursday, 10 April 2014 at 09:24:51 UTC, Paulo Pinto wrote: In a toy project I am working on with D v2.065, I came to the following situation: Node path = solver.find (map, start, end); if (path !is null) { path.writeContents(); <-- Access Violation } Apparently between the test and tr

Re: Successively prepending to slices.

2014-04-10 Thread John Colvin
On Wednesday, 9 April 2014 at 23:18:27 UTC, dnspies wrote: I know that D slices are set up so you can successively append to them and it only has to re-allocate infrequently, but what about with prepending? ie, does D have a way to handle int[] x; for(int i=0; i < 1000; i++) { x = [i] ~ x;

GC being too eager?

2014-04-10 Thread Paulo Pinto
In a toy project I am working on with D v2.065, I came to the following situation: Node path = solver.find (map, start, end); if (path !is null) { path.writeContents(); <-- Access Violation } Apparently between the test and trying to use the class, the reference becomes null. Quite stra

Re: How to set JSON_TYPE in 2.0.65

2014-04-10 Thread Nikolay
I used JSONValue rs = JSONValue([null:null]); for empty object

Re: Anyone have sucess converting MSVC 2010 COFF libs to OMF

2014-04-10 Thread Kagamin
On Wednesday, 9 April 2014 at 17:45:40 UTC, Byron wrote: Link a c library with D of course That won't work. You would need to link with c runtime. Try ldc - it compiles to coff and supports linking with msvc runtime.

Re: They are not the same

2014-04-10 Thread Kagamin
Pure functions are allowed to access mutable state without const qualifier. I don't understand, why you want the qualifier and how it would help with consistent implementation of purity.