Using Parallel prints duplicates nor misses.

2017-09-17 Thread Vino.B via Digitalmars-d-learn
Hi, Request your help, the below code sometime prints duplicate and some time miss the entry. due to which any code written below the line "foreach (d; parallel(dFiles[], 1))" are some time duplicated and some time not executed(skips). tired adding sort and uniq to the writeln but no luck.

Re: Internal error mixing templates and CTFE

2017-09-17 Thread David Bennett via Digitalmars-d-learn
On Friday, 15 September 2017 at 15:48:10 UTC, Stefan Koch wrote: are you using ucent ? Not that I know of, the code above is the full code (not sure what's used internally for string literals). I was using dmd 2.076 from the apt repo but the error also happens in LDC 1.3[1]. Is there an

How to list all process directories under /proc/

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn
Hi, I want to list all processes by scanning /proc/. The following code doesn't work [code] foreach (string fstatm; dirEntries("/proc/", "[0-9]*", SpanMode.shallow)) { writefln("pid %s", fstatm); } [/code] as it only list a few entries before exiting [code] pid /proc/9 pid

Re: How to list all process directories under /proc/

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Sunday, 17 September 2017 at 08:32:24 UTC, Ky-Anh Huynh wrote: My bad. Range doesn't support. The correct pattern is [code] foreach (string fstatm; dirEntries("/proc/", "[0123456789]*", SpanMode.shallow)) { writefln("pid %s", fstatm); } [/code] Is there a way to make this

Re: Temporarily adding -vgc to a DUB build

2017-09-17 Thread Igor via Digitalmars-d-learn
On Sunday, 17 September 2017 at 01:50:08 UTC, Nicholas Wilson wrote: On Saturday, 16 September 2017 at 21:45:34 UTC, Nordlöw wrote: How do I temporarily enable -vgc when building my app with DUB? I've tried DFLAGS=-vgc /usr/bin/dub build --build=unittest but it doesn't seem to have any

Forwarding Uncopyable Static Array Elements

2017-09-17 Thread Nordlöw via Digitalmars-d-learn
How can T[n] asStatic(T, size_t n)(T[n] arr) { import std.traits : isCopyable; static if (isCopyable!T) { return arr; } else { static assert(false, "TODO support forwarding of uncopyable elements"); } } be extended to support uncopyable element

Re: Forwarding Uncopyable Static Array Elements

2017-09-17 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 17 September 2017 at 13:00:04 UTC, Nordlöw wrote: How can ... be extended to support uncopyable element types? That is, when `T` is uncopyable.

Re: Gtk toArray List funkiness

2017-09-17 Thread Mike Wey via Digitalmars-d-learn
On 16-09-17 23:08, Joseph wrote: On Saturday, 16 September 2017 at 20:54:21 UTC, Mike Wey wrote: On 16-09-17 20:58, Joseph wrote: https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d has the code foreach ( int i, string selection ; fs.getSelections()) {

Error 16: Index Range error while building examples from D Web development

2017-09-17 Thread kerdemdemir via Digitalmars-d-learn
Hi, Thanks its price dropped to 10 Euros I bought the the D Web Development book and I were trying to build some examples. The example in Chapter3 called noteapp4 is giving me this error : Performing "debug" build using dmd for x86. noteapp4 ~master: building configuration "application"...

How to Skip some field/word in formattRead?

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn
Hi, Is it possible to read just the second word from an input string and skip all others? "one two three".formattedRead!("%s %s", _, saveme) The point is I want to skip the first/third word (`one`, `third`) and read the second word (`two`) into the variable `saveme`. For now I have to

Re: How to list all process directories under /proc/

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Sunday, 17 September 2017 at 08:15:58 UTC, Ky-Anh Huynh wrote: Hi, I want to list all processes by scanning /proc/. The following code doesn't work [code] foreach (string fstatm; dirEntries("/proc/", "[0-9]*", SpanMode.shallow)) { writefln("pid %s", fstatm); } [/code] as it

Re: Error 16: Index Range error while building examples from D Web development

2017-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 September 2017 at 11:42:16 UTC, kerdemdemir wrote: Hi, Thanks its price dropped to 10 Euros I bought the the D Web Development book and I were trying to build some examples. The example in Chapter3 called noteapp4 is giving me this error : [...] Optlink bug I guess? try

Re: Forwarding Uncopyable Static Array Elements

2017-09-17 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 17 September 2017 at 13:00:04 UTC, Nordlöw wrote: How can T[n] asStatic(T, size_t n)(T[n] arr) { import std.traits : isCopyable; static if (isCopyable!T) { return arr; } else { static assert(false, "TODO support forwarding of uncopyable

Re: How to Skip some field/word in formattRead?

2017-09-17 Thread kdevel via Digitalmars-d-learn
On Sunday, 17 September 2017 at 13:53:26 UTC, Ky-Anh Huynh wrote: Is it possible to read just the second word from an input string and skip all others? "one two three".formattedRead!("%s %s", _, saveme) --- import std.range; auto saveme = "one two three".split.array [2]; ---

Re: extern(C) enum

2017-09-17 Thread nkm1 via Digitalmars-d-learn
On Sunday, 17 September 2017 at 17:06:10 UTC, bitwise wrote: I don't really see a way to deal with this aside from branching the entire library and inserting something like 'FT_SIZE_REQUEST_TYPE__FORCE_INT = 0x' into every enum incase the devs used it in a struct. Just put the burden

Re: extern(C) enum

2017-09-17 Thread bitwise via Digitalmars-d-learn
On Saturday, 16 September 2017 at 12:34:58 UTC, nkm1 wrote: On Saturday, 16 September 2017 at 03:06:24 UTC, Timothy Foster wrote: [...] [...] So it appears I'm screwed then. Example: typedef enum FT_Size_Request_Type_ { FT_SIZE_REQUEST_TYPE_NOMINAL, FT_SIZE_REQUEST_TYPE_REAL_DIM,

OpIndex/OpIndexAssign strange order of execution

2017-09-17 Thread SrMordred via Digitalmars-d-learn
struct Test{ @property int value(){ writeln("property value : ", _value); return _value; } int _value; Test opIndex( string index ) { writeln( "opIndex : index : ", index ); return this; } Test opIndexAssign(int value, string index )

Re: extern(C) enum

2017-09-17 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 17 September 2017 at 19:16:06 UTC, bitwise wrote: On Sunday, 17 September 2017 at 18:44:47 UTC, nkm1 wrote: On Sunday, 17 September 2017 at 17:06:10 UTC, bitwise wrote: [...] Just put the burden on the users then. It's implementation defined, so they are in position to figure it

Re: extern(C) enum

2017-09-17 Thread bitwise via Digitalmars-d-learn
On Sunday, 17 September 2017 at 18:44:47 UTC, nkm1 wrote: On Sunday, 17 September 2017 at 17:06:10 UTC, bitwise wrote: [...] Just put the burden on the users then. It's implementation defined, so they are in position to figure it out... This isn't something that can really be done with

What is the canonical way to subclass Thread and make it pauseable?

2017-09-17 Thread Enjoys Math via Digitalmars-d-learn
How do you write a pauseable Thread? Thanks.

Re: Is there further documentation of core.atomic.MemoryOrder?

2017-09-17 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 13 September 2017 at 14:40:55 UTC, Nathan S. wrote: Is there a formal description of "hoist-load", "hoist-store", "sink-load", and "sink-store" as used in core.atomic.MemoryOrder (https://dlang.org/library/core/atomic/memory_order.html)? You can read this:

Re: What is the canonical way to subclass Thread and make it pauseable?

2017-09-17 Thread Enjoys Math via Digitalmars-d-learn
On Sunday, 17 September 2017 at 19:57:05 UTC, Enjoys Math wrote: How do you write a pauseable Thread? Thanks. This seems to work: module data_rates_thread; import core.thread; import std.datetime; class DataRatesThread : Thread { private: uint loopSleep; bool paused;

Propagating constness through function results

2017-09-17 Thread David Zhang via Digitalmars-d-learn
Hi, I have a class `Image`, and I have a function called `getSubImage(Rect bounds)`. What I can't figure out is how to get the result of `getSubImage()` to take on the constness of the backing image. ie. //The Image class is really just a view over a buffer that's managed elsewhere

Looking for instructions on how to make a Derelict library

2017-09-17 Thread Matt Jones via Digitalmars-d-learn
Hey everyone, I wanted to make a version of SQlite3 that uses Derelict to load the sqlite3 DLL when I'm ready. I can't find any instructions for how to make a basic Derelict style library. I looked around at http://derelictorg.github.io/, but could not find anything. Does anyone have any?

Re: Access Violation when passing the result of a C function directly to a D function?

2017-09-17 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 15 September 2017 at 04:01:13 UTC, Timothy Foster wrote: I've been calling it like so: ErrorFMOD(FMOD_System_Create(), "Error Creating System: "); Making the calls without my helper function doesn't cause an Access Violation. Calling it like this is the only thing that seems to

Re: Propagating constness through function results

2017-09-17 Thread David Zhang via Digitalmars-d-learn
On Sunday, 17 September 2017 at 21:18:08 UTC, David Zhang wrote: Hi, I have a class `Image`, and I have a function called `getSubImage(Rect bounds)`. What I can't figure out is how to get the result of `getSubImage()` to take on the constness of the backing image. ie. //The Image

Re: Propagating constness through function results

2017-09-17 Thread David Zhang via Digitalmars-d-learn
Nevermind! I rediscovered the `inout`attribute. Though if I may say so, I have no idea how `inout` is supposed to indicate "whatever the constness of a".

Re: extern(C) enum

2017-09-17 Thread Mike Parker via Digitalmars-d-learn
On Monday, 18 September 2017 at 02:04:49 UTC, bitwise wrote: On Monday, 18 September 2017 at 00:12:49 UTC, Mike Parker wrote: On Sunday, 17 September 2017 at 19:16:06 UTC, bitwise wrote: [...] I've been maintaining bindings to multiple C libraries (including Freetype 2 bindings) for 13

Re: Looking for instructions on how to make a Derelict library

2017-09-17 Thread Matt Jones via Digitalmars-d-learn
On Monday, 18 September 2017 at 00:21:23 UTC, Mike Parker wrote: See the D wiki for links to articles that show how to translate C headers. I've been reading the DerelictSDL2 source code. I think I have a handle on it. I'll have to look more at the wiki too. Thanks.

Re: Propagating constness through function results

2017-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/17/17 5:37 PM, David Zhang wrote: Nevermind! I rediscovered the `inout`attribute. Correct, inout applied to the function is actually applying to the 'this' parameter. Same as const or immutable functions as well. Though if I may say so, I have no idea how `inout` is supposed to

Re: Looking for instructions on how to make a Derelict library

2017-09-17 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 17 September 2017 at 21:15:08 UTC, Matt Jones wrote: Hey everyone, I wanted to make a version of SQlite3 that uses Derelict to load the sqlite3 DLL when I'm ready. I can't find any instructions for how to make a basic Derelict style library. I looked around at

Re: extern(C) enum

2017-09-17 Thread bitwise via Digitalmars-d-learn
On Monday, 18 September 2017 at 00:12:49 UTC, Mike Parker wrote: On Sunday, 17 September 2017 at 19:16:06 UTC, bitwise wrote: [...] I've been maintaining bindings to multiple C libraries (including Freetype 2 bindings) for 13 years now. I have never encountered an issue with an enum size