How to call function with variable arguments at runtime?

2017-10-09 Thread Mr. Jonse via Digitalmars-d-learn
I need to store a hetrogeneous array of delegates. How can I do this but still call the function with the appropriate number of parameters at run time? I have the parameters as Variant[] params and a function/delegate pointer(void* for now). Normally I'd push the parameters on the stack and

Undo?

2017-10-09 Thread Mr. Jonse via Digitalmars-d-learn
I requiring an undo feature in my code. Rather than go the regular route of using commands, I'm wondering if D can facilitate an undo system quite easily? We can think of an undo system in an app as a sort of recorder. The traditional method is to use commands and inverse-commands. By

Re: How to make commented code to compile?

2017-10-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 October 2017 at 15:15:48 UTC, Zhuo Nengwen wrote: test(cast(ushort) 1, (m, c) => { writeln(m); writeln(m); }); Just remove the => (m, c) { // code here }

Re: How to make commented code to compile?

2017-10-09 Thread Zhuo Nengwen via Digitalmars-d-learn
On Monday, 9 October 2017 at 14:54:33 UTC, Adam D. Ruppe wrote: //test(cast(ushort) 1, (m, c) => { writeln(m); }); That's a function that returns a function. Perhaps you meant to just remove the => and be left with a multi-line function. I simplified the test codes. I want write mode

Re: Add a precompiled c++ obj file to dub

2017-10-09 Thread b4s1L3 via Digitalmars-d-learn
On Sunday, 8 October 2017 at 04:03:27 UTC, user1234 wrote: On Sunday, 8 October 2017 at 02:58:36 UTC, Fra Mecca wrote: On Saturday, 7 October 2017 at 23:54:50 UTC, user1234 wrote: On Saturday, 7 October 2017 at 19:56:52 UTC, Fra Mecca wrote: Hi all, I am writing a backend that is partly

Re: How to make commented code to compile?

2017-10-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 October 2017 at 14:34:48 UTC, Zhuo Nengwen wrote: //test(cast(ushort) 1, (m, c) => { writeln(m); }); That's a function that returns a function. Perhaps you meant to just remove the => and be left with a multi-line function.

How to make commented code to compile?

2017-10-09 Thread Zhuo Nengwen via Digitalmars-d-learn
import std.stdio; void test(ushort market, void delegate(ushort market, char* pc) callback) { for (auto i = 0; i < 10; i++) { callback(cast(ushort) i, cast(char*) null); } } void main() { test(cast(ushort) 1, (m, c) => writeln(m)); //test(cast(ushort) 1, (m, c) =>

Re: Add a precompiled c++ obj file to dub

2017-10-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-08 04:58, Fra Mecca wrote: At the end I added them as linking options (lflags) but it is kinda odd that it works given that everything is supplied to dmd as -Lobj.o Everything passed to DMD with the -L flag is passed to the linker, basically as is. So if the linker accepts object

Re: Bug? ElementType fails if element type is const

2017-10-09 Thread drug via Digitalmars-d-learn
oops, it was my fault. sorry for noise. my apologies to ElementType ))

Bug? ElementType fails if element type is const

2017-10-09 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/duecIS

Re: @nogc formattedWrite

2017-10-09 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 7 October 2017 at 18:14:00 UTC, Nordlöw wrote: Is it currently possible to somehow do @nogc formatted output to string? I'm currently using my `pure @nogc nothrow` array-container `CopyableArray` as @safe pure /*TODO nothrow @nogc*/ unittest { import std.format :

Re: @nogc formattedWrite

2017-10-09 Thread Igor via Digitalmars-d-learn
On Saturday, 7 October 2017 at 18:27:36 UTC, jmh530 wrote: On Saturday, 7 October 2017 at 18:14:00 UTC, Nordlöw wrote: It would be nice to be able to formatted output in -betterC... Agreed. If you know the size of the buffer, you can use sformat, which might be @nogc, but I don't know if