Re: Temporary file creation for unittests

2018-05-20 Thread Joakim via Digitalmars-d-learn
On Friday, 18 May 2018 at 15:16:52 UTC, Russel Winder wrote: Hi, What's the current official position on how to create temporary files for use during a unittest. I found https://github.com/dlang/phobos/pull/5788 but it seems to be languishing in the "we have discussed all the issues that no

Re: C style callbacks fix for member callbacks

2018-05-20 Thread ag0aep6g via Digitalmars-d-learn
I tried this. Your code crashes in windows dmd x86 x64. Hm. Works for me in a virtual machine. But I'm not surprised that it's fragile. It might be completely wrong, and it just happens to look alright on my machine.

Re: C style callbacks fix for member callbacks

2018-05-20 Thread IntegratedDimensions via Digitalmars-d-learn
On Sunday, 20 May 2018 at 23:05:47 UTC, ag0aep6g wrote: On 05/20/2018 06:48 PM, IntegratedDimensions wrote: alias callback = extern(C) int function(const(void) a, void *b, uint c, void* context); (I'm assuming that `a` is supposed to be a `const(void)*`.) Where context acts as this. I would

Re: C style callbacks fix for member callbacks

2018-05-20 Thread ag0aep6g via Digitalmars-d-learn
On 05/20/2018 06:48 PM, IntegratedDimensions wrote: alias callback = extern(C) int function(const(void) a, void *b, uint c, void* context); (I'm assuming that `a` is supposed to be a `const(void)*`.) Where context acts as this. I would like to assign a D method to this callback. class {   

Re: Convert mixin to function call

2018-05-20 Thread IntegratedDimensions via Digitalmars-d-learn
It should be obvious that these are simplifications. I can't pass the variables directly as parameters as in the real case the names may only be partially specified.

Re: Convert mixin to function call

2018-05-20 Thread IntegratedDimensions via Digitalmars-d-learn
https://dpaste.dzfl.pl/fb49bf834cff import std.stdio; auto Q(string A)() { auto foo() { auto d = mixin(Z!(A)()); return d; } return foo()(); } auto X(string A, string N)() { return N~" = (() { int y = 4; return "~A~" + y +

Re: Convert mixin to function call

2018-05-20 Thread IntegratedDimensions via Digitalmars-d-learn
Also, one thing that would help would be able to create identifier names that are unique to avoid collisions. Does D have any ability to do such a thing?

Convert mixin to function call

2018-05-20 Thread IntegratedDimensions via Digitalmars-d-learn
I have a string mixin that returns a value or function that uses the mixed in scope. Currently I have to wrap the mixin in a delegate or local function as to be able to get the value: int x = 3; int y = 1; auto foo() { mixin(X!("x")); } This allows the the mixin to see the scope but keep the

Re: auto & class members

2018-05-20 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-20 17:40:39 +, Robert M. Münch said: Hi Jonathan, great! This got me a step further. So I can declare my member now. But I get an implict cast error when I try: class a { ... myStream; } class b { typeof(a.myStream.filter!(x => x == myMessage)) mySubStream; } v

Re: auto & class members

2018-05-20 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-20 14:49:59 +, Jonathan M Davis said: In cases like this, typeof is your friend. e.g. something like typeof(myStream.filter!(a => a == myMessage)) mySubStream; Hi Jonathan, great! This got me a step further. So I can declare my member now. But I get an implict cast error when

Re: C style callbacks fix for member callbacks

2018-05-20 Thread IntegratedDimensions via Digitalmars-d-learn
On Sunday, 20 May 2018 at 08:40:57 UTC, MGW wrote: On Saturday, 19 May 2018 at 23:52:58 UTC, IntegratedDimensions wrote: I have a member callback that I want to use as a C callback. http://www.agner.org/optimize/calling_conventions.pdf https://www.youtube.com/watch?v=xhDS377mAc4 Sorry, I c

Mysql query result access by field name

2018-05-20 Thread ipkwena via Digitalmars-d-learn
I have started learning D and I am enjoying it so far. How does one access the columns fields in a Mysql query results by the column name. Currently I have to use the method as shown in a couple of example by indexing array values (f being a struct variable): Data f; f.name =

Re: auto & class members

2018-05-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 20, 2018 16:30:10 Robert M. Münch via Digitalmars-d-learn wrote: > I use the D RX lib [1] and can create a filtered stream using the auto > keyword: > > struct a { > SubjectObject!myType myStream; > ??? mySubStream; > } > > void myfunc(){ > a myA = new a(); > > auto mySubStr

auto & class members

2018-05-20 Thread Robert M. Münch via Digitalmars-d-learn
I use the D RX lib [1] and can create a filtered stream using the auto keyword: struct a { SubjectObject!myType myStream; ??? mySubStream; } void myfunc(){ a myA = new a(); auto mySubStream = a.myStream.filter!(a => a == myMessage); ... } The problem is,

Re: Can I infer the type from this?

2018-05-20 Thread Alex via Digitalmars-d-learn
On Sunday, 20 May 2018 at 03:16:39 UTC, Dr.No wrote: Oh, my bad: I totally forgot a crucial thing on question: I want this to work with a static member, for example, call myTemp like this myTemp!(C.a) I don't mind if I to pass the type as parameter somehow, like myTemp!(C, C.a) or myTemp!(C)

Re: C style callbacks fix for member callbacks

2018-05-20 Thread MGW via Digitalmars-d-learn
On Saturday, 19 May 2018 at 23:52:58 UTC, IntegratedDimensions wrote: I have a member callback that I want to use as a C callback. http://www.agner.org/optimize/calling_conventions.pdf https://www.youtube.com/watch?v=xhDS377mAc4

Re: Examples/tutorials for OpenGL games which works out-of-the-box on linux

2018-05-20 Thread rikki cattermole via Digitalmars-d-learn
On 20/05/2018 8:06 PM, Prokop Hapala wrote: Hi, I'm looking for examples of OpenGL games which I can use as templates for making my own stuff. But I'm quite discouraged that everything I found on github is probably outdated and fails to compile. Since I'm not very familiar with dub environmen

Examples/tutorials for OpenGL games which works out-of-the-box on linux

2018-05-20 Thread Prokop Hapala via Digitalmars-d-learn
Hi, I'm looking for examples of OpenGL games which I can use as templates for making my own stuff. But I'm quite discouraged that everything I found on github is probably outdated and fails to compile. Since I'm not very familiar with dub environment I don't feel able to correct the errors in