Pass lambda into template

2018-09-03 Thread Andrey via Digitalmars-d-learn
Hello, Here is a code with comments: https://run.dlang.io/is/BNl2Up. I don't understand how to pass lambda into template. I get an error: onlineapp.d(18): Error: template instance `qwerty!((i) => "arg" ~ i.to!string ~ "[0] == '?'", "||")` cannot use local __lambda1 as parameter to non-global

Re: Load entire file, as a char array.

2018-09-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/09/2018 7:38 PM, Chris Katko wrote: On Monday, 3 September 2018 at 06:28:38 UTC, bauss wrote: On Monday, 3 September 2018 at 06:25:23 UTC, bauss wrote: On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh wrote: On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko wrote: This

Re: Load entire file, as a char array.

2018-09-03 Thread bauss via Digitalmars-d-learn
On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh wrote: On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko wrote: This should be simple? All I want to do is load an entire file, and access individual bytes. The entire thing. I don't want to have know the file size before hand,

Re: Load entire file, as a char array.

2018-09-03 Thread bauss via Digitalmars-d-learn
On Monday, 3 September 2018 at 06:25:23 UTC, bauss wrote: On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh wrote: On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko wrote: This should be simple? All I want to do is load an entire file, and access individual bytes. The entire

Re: Load entire file, as a char array.

2018-09-03 Thread Chris Katko via Digitalmars-d-learn
On Monday, 3 September 2018 at 06:28:38 UTC, bauss wrote: On Monday, 3 September 2018 at 06:25:23 UTC, bauss wrote: On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh wrote: On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko wrote: This should be simple? All I want to do is load

Re: Load entire file, as a char array.

2018-09-03 Thread Chris Katko via Digitalmars-d-learn
On Monday, 3 September 2018 at 07:38:51 UTC, Chris Katko wrote: On Monday, 3 September 2018 at 06:28:38 UTC, bauss wrote: On Monday, 3 September 2018 at 06:25:23 UTC, bauss wrote: On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh wrote: On Monday, 3 September 2018 at 03:04:57 UTC,

Re: Pass lambda into template

2018-09-03 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 3 September 2018 at 09:09:44 UTC, Andrey wrote: Hello, Here is a code with comments: https://run.dlang.io/is/BNl2Up. I don't understand how to pass lambda into template. I get an error: onlineapp.d(18): Error: template instance `qwerty!((i) => "arg" ~ i.to!string ~ "[0] == '?'",

Re: anyway to debug nogc code with writeln?

2018-09-03 Thread aliak via Digitalmars-d-learn
On Saturday, 1 September 2018 at 22:38:46 UTC, Ali Çehreli wrote: You can strip off any attribute with SetFunctionAttributes: import std.stdio; // Adapted from std.traits.SetFunctionAttributes documentation import std.traits; auto assumeNoGC(T)(T t) if (isFunctionPointer!T || isDelegate!T)

Re: DStep rocks [was Example of using C API from D?]

2018-09-03 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2018-09-02 at 21:54 +, Laeeth Isharc via Digitalmars-d- learn wrote: > On Sunday, 2 September 2018 at 17:49:45 UTC, Russel Winder wrote: > > […] > > Now to work out how to make the project auto generate this D > > module so as to avoid having it in the repository, and > >

Re: DStep rocks [was Example of using C API from D?]

2018-09-03 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 3 September 2018 at 10:50:17 UTC, Russel Winder wrote: Interesting alternative to DStep. I came to D to avoid #include, but… I'll give it a whirl once I can get it compiled on Debian Sid. It seems the libclang-dev package does not install a libclang.so symbolic link, you have to be

Re: DStep rocks [was Example of using C API from D?]

2018-09-03 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2018-09-03 at 12:45 +, Andrea Fontana via Digitalmars-d- learn wrote: > […] > > I use dpp to generate d code to import: > - Create a temp.dpp file with #include inside > - Run "d++ --preprocess-only temp.dpp" > > Now you have your .d file exactly like in dstep. > So where does this

Re: Structures and CTFE

2018-09-03 Thread bauss via Digitalmars-d-learn
On Monday, 3 September 2018 at 13:39:25 UTC, agorkvmh wrote: Hi all, Running this: --- static assert(Foo(1).pos == 2); struct Foo { this(int i){ advance(); } size_t pos =1; void advance() { pragma(msg, pos); pos = pos+1; pragma(msg, pos); } } dmd

Re: Structures and CTFE

2018-09-03 Thread agorkvmh via Digitalmars-d-learn
On Monday, 3 September 2018 at 13:52:24 UTC, bauss wrote: On Monday, 3 September 2018 at 13:39:25 UTC, agorkvmh wrote: [...] It prints 1, because pragma(msg) is called when the compiler is analyzing the code through the semantic process and not when the body of the function is executed

Meson issue with -L--export-dynamic flag

2018-09-03 Thread Gerald via Digitalmars-d-learn
Myself and some others are looking at replacing autotools in Tilix with meson for the various Linux distros to use when building and packaging the binary. However we are running into an issue with meson around the use of the "-L--export-dynamic" flag. When compiling with meson using LDC and

Re: Meson issue with -L--export-dynamic flag

2018-09-03 Thread Gerald via Digitalmars-d-learn
For anyone that wants to try to reproduce it, you can clone this repo and switch to the meson branch: https://github.com/bilelmoussaoui/tilix

Re: Is there any reason to use non-ref foreach?

2018-09-03 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 31 August 2018 at 09:59:20 UTC, Dukc wrote: For me, it seems that for generality you should always add ref into foreach loop variable. The reason is this: One good reason: https://forum.dlang.org/thread/dlhrrgvzmhladnphi...@forum.dlang.org

Structures and CTFE

2018-09-03 Thread agorkvmh via Digitalmars-d-learn
Hi all, Running this: --- static assert(Foo(1).pos == 2); struct Foo { this(int i){ advance(); } size_t pos =1; void advance() { pragma(msg, pos); pos = pos+1; pragma(msg, pos); } } dmd -o- -unittest source/pgs/parser.d 1LU 1LU --- The static

Re: assumeNoGC works but can't get an assumePure to work

2018-09-03 Thread Paul Backus via Digitalmars-d-learn
On Monday, 3 September 2018 at 22:07:10 UTC, aliak wrote: Why does it work with nogc but not with pure? Cheers, - Ali You can't define an impure function inside a pure unittest. If you move `modify` outside the unittest block, and change the argument from a lambda to a function pointer, it

Re: Structures and CTFE

2018-09-03 Thread Alex via Digitalmars-d-learn
On Monday, 3 September 2018 at 14:00:23 UTC, agorkvmh wrote: There is a way to do print the two values at compile time? Yes. Put a pragma where you static assert for Foo(1).pos equality with 2: -- static assert(Foo(1).pos == 2); pragma(msg, Foo(1).pos); struct Foo { this(int i)

Re: Structures and CTFE

2018-09-03 Thread agorkvmh via Digitalmars-d-learn
On Monday, 3 September 2018 at 15:00:33 UTC, Alex wrote: On Monday, 3 September 2018 at 14:00:23 UTC, agorkvmh wrote: [...] Yes. Put a pragma where you static assert for Foo(1).pos equality with 2: [...] Thanks, by the way, the autocomplete suggests me '__ctfeWrite', what is it?

Re: Structures and CTFE

2018-09-03 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 3 September 2018 at 15:08:57 UTC, agorkvmh wrote: On Monday, 3 September 2018 at 15:00:33 UTC, Alex wrote: On Monday, 3 September 2018 at 14:00:23 UTC, agorkvmh wrote: [...] Yes. Put a pragma where you static assert for Foo(1).pos equality with 2: [...] Thanks, by the way,

Process in parallel and output result to stdout theread-safely

2018-09-03 Thread Dr.No via Digitalmars-d-learn
so I'im doing an expansive operation with a file, to try speed up, i switch to using parallel but keeping in the otuput printing thread-safe. But for some reason, even using synchonized, it doesn't work as expected, for example, it output multiples results on same time, as in the example

Re: Pass lambda into template

2018-09-03 Thread vit via Digitalmars-d-learn
On Monday, 3 September 2018 at 09:09:44 UTC, Andrey wrote: Hello, Here is a code with comments: https://run.dlang.io/is/BNl2Up. I don't understand how to pass lambda into template. I get an error: onlineapp.d(18): Error: template instance `qwerty!((i) => "arg" ~ i.to!string ~ "[0] == '?'",

Re: Pass lambda into template

2018-09-03 Thread Paul Backus via Digitalmars-d-learn
On Monday, 3 September 2018 at 09:09:44 UTC, Andrey wrote: Hello, Here is a code with comments: https://run.dlang.io/is/BNl2Up. I don't understand how to pass lambda into template. I get an error: onlineapp.d(18): Error: template instance `qwerty!((i) => "arg" ~ i.to!string ~ "[0] == '?'",

assumeNoGC works but can't get an assumePure to work

2018-09-03 Thread aliak via Digitalmars-d-learn
In another thread [0] this function can be used to call non nogc code from nogc code import std.traits; auto assumeNoGC(T)(T t) { enum attrs = functionAttributes!T | FunctionAttribute.nogc; return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t; } And then you can use it