Re: try & catch / repeating code - DRY

2018-05-24 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-22 18:33:06 +, Jacob Carlborg said: You can always create a function that takes a delegate or lambda and handles the exception in the function. Here are three versions of the same thing, depending on how you want the call site to look like. Hi, great! Thanks for the

Re: try & catch / repeating code - DRY

2018-05-23 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-22 18:34:34 +, Ali ‡ehreli said: An idiom known in C++ circles is a Lippincott function: https://cppsecrets.blogspot.ca/2013/12/using-lippincott-function-for.html Just wanted to mention that it can be a part of a clean solution. Thanks, and I assume that D has the same

try & catch / repeating code - DRY

2018-05-22 Thread Robert M. Münch via Digitalmars-d-learn
I see that I'm writing try { ... different code ... } catch (myException e) { ... same handling code ... } over and over again. Of course I can put the exception handling code into a function to not duplicate it. However, I still need to write this construct over and over again. Is

Re: auto & class members

2018-05-22 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-21 18:55:36 +, Steven Schveighoffer said: So the issue here is that the lambda function inside myFunc is DIFFERENT than the one inside b. They are both the same function, but with essentially different names. Aha... that explains it pretty good. When you use the alias, both

Re: auto & class members

2018-05-22 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-21 20:17:04 +, Jonathan M Davis said: On Monday, May 21, 2018 16:05:00 Steven Schveighoffer via Digitalmars-d- learn wrote: Well one thing that seems clear from this example -- we now have __traits(isSame) to tell if lambdas are the same, but it looks like the compiler doesn't

Re: auto & class members

2018-05-22 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-21 18:13:16 +, Ali ‡ehreli said: Templatized range types work well when they are used as template arguments themselves. When you need to keep a single type like 'b' (i.e. b is not a template), and when you need to set a variable like mySubStream to a dynamic object, the

Re: scope guards & debugger breakpoints?

2018-05-21 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-21 17:24:12 +, Steven Schveighoffer said: I'm not 100% sure but I expect: scope(failure) someCode(); putting a breakpoint on someCode should work. When calling a function an then setting the breakpoint there, like in someCode() yes, that should work. I used code like

VisualD / fatal error C1905: Front-End and Back-End are not compatible (have to use the same processor)

2018-05-21 Thread Robert M. Münch via Digitalmars-d-learn
A project I can compile via the command line and dub, gives an error in VisualD. I created the VisualD configuration through dub: fatal error C1905: Front-End und Back-End sind nicht kompatibel (müssen den gleichenProzessor verwenden). This translates to: "Front-End and Back-End are not

scope guards & debugger breakpoints?

2018-05-21 Thread Robert M. Münch via Digitalmars-d-learn
If I use scope(failure) with code that should be run if an exception is thrown, how can I set a breakpoint for this code in the debugger? -- Robert M. Münch http://www.saphirion.com smarter | better | faster

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; }

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

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

Re: C API / const char *text / std.string.toStringz pointer is always NULL on C side

2018-05-19 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-18 14:42:17 +, Adam D. Ruppe said: On Friday, 18 May 2018 at 14:06:11 UTC, Robert M. Münch wrote: So, having a wrong return-type here, resulted in the const char *text parameter always being NULL. Not sure I understand the relation but looks strange to me... at least not very

Re: C API / const char *text / std.string.toStringz pointer is always NULL on C side

2018-05-18 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-16 17:46:59 +, Steven Schveighoffer said: Well, for C see above on the D side: extern(C) {   result myfunc(double x, double y, const char *text, stuff *myStuff, bool measureOnly); } Shouldn't the result be a pointer? Indeed. And you know what? That was

Re: C API / const char *text / std.string.toStringz pointer is always NULL on C side

2018-05-16 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-16 15:09:41 +, rikki cattermole said: On 17/05/2018 3:07 AM, Robert M. Münch wrote: I have an extern(C) function in a DLL with this signature: result* myfunc(double x, double y, const char *text, stuff *myStuff, bool flag); I call it like this: result = myfunc(0, 0,

C API / const char *text / std.string.toStringz pointer is always NULL on C side

2018-05-16 Thread Robert M. Münch via Digitalmars-d-learn
I have an extern(C) function in a DLL with this signature: result* myfunc(double x, double y, const char *text, stuff *myStuff, bool flag); I call it like this: result = myfunc(0, 0, std.string.toStringz("1"), stuff, true); The problem is, that on the DLL side *text is always NULL. I

C++ / const class pointer signature / unable to find correct D syntax

2018-05-04 Thread Robert M. Münch via Digitalmars-d-learn
I have a static C++ and can't make it to get a correct binding for one function: DMD: public: unsigned int __cdecl b2d::Context2D::_begin(class b2d::Image & __ptr64,class b2d::Context2D::InitParams const * __ptr64 const) __ptr64 LIB: public: unsigned int __cdecl b2d::Context2D::_begin(class

Re: C++ / Wrong function signature generated for reference parameter

2018-05-03 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-03 09:34:56 +, kinke said: That's why there's `extern(C++, class) struct Image`, see https://dlang.org/spec/cpp_interface.html#classes. Hi, thanks. I didn't understand the docs as without any code examples for all the different cases, it's hard to derive the syntax and how to

Re: C++ / Wrong function signature generated for reference parameter

2018-05-03 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-03 02:23:27 +, Rubn said: You want to use a struct which isn't passed by pointer, but by value. Which will then give you the signature you want. In addition to my other post, using struct won't give the correct signature. That's the signature I need: public: unsigned int

Re: C++ / Wrong function signature generated for reference parameter

2018-05-03 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-03 02:23:27 +, Rubn said: If "Image" is a class then all classes are based as pointers to their respective object. Hi, ok. Didn't remember that this is always the case. So passing a ref to a class is kind of redundant. Yes, that's why I was confused. You want to use a

C++ / Wrong function signature generated for reference parameter

2018-05-02 Thread Robert M. Münch via Digitalmars-d-learn
I have the following C++ function signature: uint _begin(Image& image, const InitParams* initParams) and the following D code: class InitParams { } class B2D { uint _begin(ref Image image, InitParams initParams); } But this compiles to the following signature which is not found by

Re: Digger v3.0 alpha 5 / DMD 2.080.0 / Can't build...

2018-05-02 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-02 09:39:41 +, Seb said: Works fine for me with 2.080.0. Did you maybe modify your working directory locally? Hi, not that I know about... If so, try nuking `work` away. I did and digger downloaded a bunch of things and failed wiht this: D:\develop\d-language\Digger>

Digger v3.0 alpha 5 / DMD 2.080.0 / Can't build...

2018-05-02 Thread Robert M. Münch via Digitalmars-d-learn
Hi, digger won't build because it sees some local changes to file, which I didn't do: D:\develop\d-language\Digger> ./digger build --model=64 digger: Building spec: master digger: Adding D:\develop\d-language\Digger\work\dl\git\cmd to PATH. digger: Updating repo... Fetching origin digger:

Re: Interfacing with C++ Class named Object

2018-05-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-01 17:14:53 +, Robert M. Münch said: Yes, great! Thanks. I could extend the code now. But I get a next problem: extern (C++, b2d) { class AnyBase { bool isShared(); } pragma(mangle, "Object"); class b2dObject : AnyBase { } class Image : b2dObject { // class

Re: Interfacing with C++ Class named Object

2018-05-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-01 16:07:30 +, Timoses said: On Tuesday, 1 May 2018 at 15:24:09 UTC, Robert M. Münch wrote: Hi, I'm mostly doing simple C-API wrappers around C++ code to access thigns from D. However, I wanted to try how far I can come using C++ directly. I have the following C++ code in

Interfacing with C++ Class named Object

2018-05-01 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I'm mostly doing simple C-API wrappers around C++ code to access thigns from D. However, I wanted to try how far I can come using C++ directly. I have the following C++ code in namespace N: class Image : public Object { Error create(int w, int h, uint32_t p) noexcept; } And I have

Re: extern (c) struct ?

2018-03-08 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-03-08 16:03:57 +, Adam D. Ruppe said: How are you accessing it? If it is by pointer only passing it to methods, you can simply: struct my_cpp_struct; and define functions: extern(C) void foo(my_cpp_struct* arg); Hi, :-/ seems I was a bit confused by all the backs and forth on

Re: dub / win 64 / unresolved externals from run-time lib?

2018-03-08 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-03-08 17:24:32 +, kinke said: On Thursday, 8 March 2018 at 17:03:18 UTC, Robert M. Münch wrote: Using Dub and pretty simple setup, that links in 3 C/C++ static libraries, I get these linker errors: libyogacore.lib(Yoga.obj) : error LNK2019: unresolved external symbol __imp_fmodf

dub / win 64 / unresolved externals from run-time lib?

2018-03-08 Thread Robert M. Münch via Digitalmars-d-learn
Using Dub and pretty simple setup, that links in 3 C/C++ static libraries, I get these linker errors: libyogacore.lib(Yoga.obj) : error LNK2019: unresolved external symbol __imp_fmodf referenced in function "void __cdecl YGRoundToPixelGrid(struct YGNode * const,float,float,float)"

extern (c) struct ?

2018-03-08 Thread Robert M. Münch via Digitalmars-d-learn
I have a pretty complex struct with C++ typed private members etc. in it which I want to use from D. Obviously I don't want to/can't rebuild the struct definiton in D and I don't need access to all the members just some simple C API ones are enough. How can I get access to this struct from

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-03-05 20:11:06 +, H. S. Teoh said: Walter has been adamant that we should always compute std.math.* functions with the `real` type, which on x86 maps to the non-IEEE 80-bit floats. However, 80-bit floats have been deprecated for a while now, Hi, do you have a reference for this?

Re: How to use globals correctly?

2018-03-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-03-05 18:57:01 +, Steven Schveighoffer said: On 3/5/18 1:35 PM, Robert M. Münch wrote: 1. Are myMemb1..N TLS or __gshared as well? No, they are on the heap. Only the reference is __gshared. But effectively it is __gshared, since you can reach those items via the global

How to use globals correctly?

2018-03-05 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I'm feeling a bit dumb but anway... For hacking prototypes I mostly create a class to store all kind of values. Then I create one global instance of this class and use it everywhere. Pseudocode looks like this: class myClass { myMemb1; myMembN; this(){...} }

Re: Function template declaration mystery...

2018-03-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-03-01 12:01:19 +, Steven Schveighoffer said: Ok, here it is: https://pastebin.com/tKACi488 See lines 81-84 for how I call it. And the problem I have is that doSubscribe returns "something" I'm not sure what I can do with. But if the scope ends, my subscription seems to be deleted

Re: Function template declaration mystery...

2018-02-28 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-02-28 18:25:37 +, Steven Schveighoffer said: unaryFun is a template that returns a callable item. That far I made it too :-) It could be a struct with an opCall, it could be a function template, it could be an alias to a real function, it could be a function pointer, delegate,

Re: Function template declaration mystery...

2018-02-28 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-02-28 18:09:41 +, H. S. Teoh said: Basically, the `alias f` is a catch-all template parameter that can bind to basically anything that has a symbol. It's typically used to bind to functions, delegates, and lambdas. Aha... ok that makes it a bit more clear. So, if I have: auto

Re: Function template declaration mystery...

2018-02-28 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-02-28 18:01:50 +, TheFlyingFiddle said: Testing this with: auto foo(alias f, A)(auto ref A a) { return f(a); } I can call foo either like this: foo!(x => x + x)(1); or 1.foo!(x => x + x); but these will give errors foo(1, x => x + x); //Error 1.foo(x => x + x); // Error I

Function template declaration mystery...

2018-02-28 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I'm lost reading some code: A a; auto do(alias f, A)(auto ref A _a){ alias fun = unaryFun!f; return ... ... } How is this alias stuff working? I mean what's the type of f? Is it an anonymous function which then gets checked to be unary? How is it recognized in the

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-07 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-06 14:33:57 +, Marc Schütz said: I don't see why this wouldn't work, if you've in fact covered all combinations. It works, the problem was that castSwitch returns something and I didn't "catch" it. It's similar to how castSwitch is implemented, though the double casts are

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-05 15:23:53 +, Marc Schütz said: Does the following help? ... I thought about it too, but I need it to work with more then one parameter, so I tried this which doesn't work: Value nativePlus(Value a, Value b){ // @@ not working, runtime exception castSwitch!( (IntV a)

Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Robert M. Münch via Digitalmars-d-learn
From the docs: class A { } class B : A { } class C : B { } void foo(A); void foo(B); void test() { C c; foo(c); // calls foo(B) } I need the other way around. So, at runtime I get an A and depending on it's dynamic type, I would like to get the correct foo() called. class A { }

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-05 11:10:36 +, Nicholas Wilson said: sounds like foo should just be a method in the class rather than a free function In my particular case I want to keep some stuff outside of claases. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: DMD OSX / Segfault 11

2016-02-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-03 14:35:16 +, Steven Schveighoffer said: On 2/3/16 8:17 AM, Robert M. Münch wrote: On 2016-02-02 18:59:35 +, Steven Schveighoffer said: If this is valid D, I'm not sure what it means :) There was one type, the rest I stripped totally away as IMO it's not relevant for

Re: DMD OSX / Segfault 11

2016-02-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-03 13:29:15 +, anonymous said: Still missing "class". I know I'm being pedantic, but if you're being sloppy here, how do I know that you're not being sloppy where it matters? You are right, sorry. I was to focused on the problem part... If anything, you should be casting

Re: DMD OSX / Segfault 11

2016-02-03 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-02 18:59:35 +, Steven Schveighoffer said: If this is valid D, I'm not sure what it means :) There was one type, the rest I stripped totally away as IMO it's not relevant for the actual problem. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

DMD OSX / Segfault 11

2016-02-02 Thread Robert M. Münch via Digitalmars-d-learn
I have a very strange effect, I'm not sure what it is about: Value: {} WordV: Value { Value* get() {} } BaseOperator: Value : { } Now comes the code using this: auto op = cast(BaseOperator)(Word.get()); if (op !is null) {... If get() returns "Value*" it segfaults, if I change it

casting & templates

2016-01-31 Thread Robert M. Münch via Digitalmars-d-learn
I have: class OperatorV(T) : Value { T impl; this(T impl) { this.impl = impl; } ... and use it like this: makeOperator((IntV a, IntV b) => new IntV(a.num + b.num)); Now I want to do: opWord.get() returns a Value OperatorV *op = cast(OperatorV*)(opWord.get()); and get: Error: class

Digger 2.4 & DMD 2.070.0

2016-01-27 Thread Robert M. Münch via Digitalmars-d-learn
Just compiled the latest release with digger. Everything works without any problems, but the resulting binary shows the following version: mac-pro:Digger robby$ ./result/bin/dmd --version DMD64 D Compiler v2.069-devel-682687b Copyright (c) 1999-2015 by Digital Mars written by Walter Bright I

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-16 20:28:02 +, Dibyendu Majumdar said: I have installed DMD by unzipping the DMD archive (The installer does not work correctly on Windows 10). DUB installed as normal. Check your paths in sc.ini Looks like the D link libraries are not found. -- Robert M. Münch

Re: DUB & Win-10 SDK / link lib not found

2016-01-15 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-15 00:36:57 +, Mike Parker said: Did you install DMD manually? In that case, you will usually need to edit sc.ini to point to the proper VC and Win SDK directories. The DMD installer should detect your installation and configure it for you. I use Digger, hence this might be

DUB & Win-10 SDK / link lib not found

2016-01-14 Thread Robert M. Münch via Digitalmars-d-learn
I was expecting that DUB / DMD & NMAKE take $LIB into account. I try to compile some stuff on x64. This is LIB: D:\develop\d-language\webchat> $Env:lib C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio

Re: DUB & Win-10 SDK / link lib not found

2016-01-14 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-14 17:40:44 +, Robert M. Münch said: I was expecting that DUB / DMD & NMAKE take $LIB into account. I try to compile some stuff on x64. This is LIB: D:\develop\d-language\webchat> $Env:lib C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files

Re: Setting up dmd properly

2016-01-12 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-12 04:15:36 +, Mike Parker said: You can avoid all of these headaches by using dynamic bindings like those at DerelictOrg [4] if they are available for the libraries you use. Then the compile-time dependency on the C library goes away and all you need is the DLL at runtime. I

Re: cairo(D) / x64 / unresolved externals / don't know why

2016-01-11 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-11 06:53:51 +, Benjamin Thaut said: You should not need to link manually against msvcrt, dmd does this for you. Ok, that was what I expected. You can view the linker commands that are stored inside a object file via microsoft dumpbin tool "dumpbin /DIRECTIVES your.obj".

Re: Setting up dmd properly

2016-01-10 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-11 01:47:54 +, Jason Jeffory said: and how does one link in compiled static libraries into a dub project? I tried adding stuff like "lflags" : ["+C:\\MyLibs\\"], with the .lib file in it, but that doesn't work. (I'd expect to have to supply the file name somewhere, at least)

cairo(D) / x64 / unresolved externals / don't know why

2016-01-10 Thread Robert M. Münch via Digitalmars-d-learn
I made to compile a bunch of libs on Win64 and got my D project compiled as well. Only problem left are some strange unresolved externals. Linking... dmd -of.dub\build\application-debug-windows-x86_64-dmd_2069-F0A1450B9B033D5CD11F3F60481557B0\webchat.exe

Re: vibe / how to use the Win32EventDriver ?

2016-01-08 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-07 20:14:15 +, Daniel Kozak via Digitalmars-d-learn said: I remember e few days I have same issue but with libasync. I have to remove .dub from my home directory (I do not know where is it in windows) and after making new project I was able to make it works Just to be sure I

Re: vibe / how to use the Win32EventDriver ?

2016-01-08 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-07 15:35:24 +, Robert M. Münch said: When I build for Windows, it seems that the "libevent" driver is used. I can see that there is a "Win32EventDriver" which setups a GUI message loop as well. How can I use this driver instead of the "libevent" one? Ok, after fiddling around

vibe.d / GUI integration

2015-12-28 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I have two questions regarding the following, IMO very cool, vibe feature: "Contrary to most other frameworks supporting asynchronous I/O, vibe.d fully integrates with the UI event loop, so that it can be used to power applications with a graphical user interface." 1. Am I right, that

deep copying / .dup / template object.dup cannot deduce function from argument types

2015-12-13 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I just wanted to naively copy an object and used: a = myobj.dup; and get the following error messages: source/app.d(191): Error: template object.dup cannot deduce function from argument types !()(BlockV), candidates are: /Library/D/dmd/src/druntime/import/object.d(1872):

Re: spawn X different workers & wait for results from all of them

2015-09-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-09-04 17:32:48 +, Justin Whear said: How would receive know? Well, it could be pretty simple. At the moment: receive( int ..., long ..., myStruct ... ) Will wait for one out of the three. So it's an OR. reveive_all( int ..., long ...,

Re: spawn X different workers & wait for results from all of them

2015-09-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-09-05 15:44:02 +, thedeemon said: I think the Task and taskPool from std.parallelism are a good fit. Something like: auto task1 = task!fun1(params1); auto task2 = task!fun2(params2); auto task3 = task!fun3(params3); auto task4 = task!fun4(params4); taskPool.put(task1);

spawn X different workers & wait for results from all of them

2015-09-03 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I'm not sure how to best implement the following: 1. I have 4 different tasks to do. 2. All can run in parallel 3. Every task will return some result that I need Now how to best do it? When using receive() it fires on the first hit and the function continues. It's like a receive(OR), one

Digger 2.3 / Win32 / 'run' not found

2015-09-03 Thread Robert M. Münch via Digitalmars-d-learn
After getting Digger to work again on OSX now going for the Windows version: digger: Preparing DigitalMars C++ digger: DMC=Y:\Digger\dl\dm\bin digger: Preparing DMD digger: hostDC= digger: Running: "make" -f win32.mak ^"MODEL=32^" HOST_DC= dmd digger:

Re: Digger 2.3 & verstr.h problem

2015-09-02 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-08-23 17:01:07 +, Vladimir Panteleev said: Can't reproduce this on Windows, Linux or OS X 10.10.3. Can you include more of the build log (specifically, the entire failing command line)? It should have a -J. in it. I still try to get digger running on my OSX again. I fiddled

Re: Digger 2.3 & verstr.h problem

2015-09-02 Thread Robert M. Münch via Digitalmars-d-learn
Some more tests with a simple example: import std.stdio; void main() { writeln("hello world!" ~ import("signature.h")); } mac-pro:d-language robby$ dmd -v -J. hello.d binarydmd version v2.068.0 config/usr/local/bin/dmd.conf parse hello importall hello importobject

Re: Digger 2.3 verstr.h problem

2015-08-27 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-08-25 13:42:38 +, Vladimir Panteleev said: And, any idea how I can print getcwd() during compile time? I tried but it's not working by using the function directly... this is really strange. getcwd() doesn't work during compile time because it's a system call. I really don't

Re: Digger 2.3 verstr.h problem

2015-08-25 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-08-24 14:27:52 +, Vladimir Panteleev said: Well, yes, your problem is that DMD 2.067 isn't finding a file while compiling DMD HEAD. So you would need to debug DMD 2.067 to find why it refuses to compile DMD HEAD. Any way that I can switch to 2.068 for building HEAD? Not that I

Re: Digger 2.3 verstr.h problem

2015-08-24 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-08-23 16:23:57 +, John Colvin said: almost certainly a consequence of the recent switchover to the dmd frontend being written in D. Have you tried building the latest Digger git HEAD first? If that doesn't work I suggest reporting it here for Vladimir (CyberShadow) to look at:

Re: Digger 2.3 verstr.h problem

2015-08-24 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-08-23 20:13:38 +, Vladimir Panteleev said: Not really sure what's going on there... If I could reproduce it, I'd try building DMD manually - if it still occurred, build DMD 2.067.1 from source and add debugging printfs to see why it's not finding verstr.h. I'm not building

Re: Digger 2.3 verstr.h problem

2015-08-24 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-08-24 11:01:47 +, John Colvin said: Is this from a clean clone of Digger, either with --recursive or having done git submodule update --init ? What version of DMD are you using to build it? Hi, no it was not. Doing a git submodule update --init fixed this problem. After this,

Re: Digger 2.3 verstr.h problem

2015-08-23 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-08-23 17:01:07 +, Vladimir Panteleev said: Can't reproduce this on Windows, Linux or OS X 10.10.3. Ok, good. So it should be fixable on my side. Can you include more of the build log (specifically, the entire failing command line)? It should have a -J. in it. CC=g++

Digger 2.3 verstr.h problem

2015-08-23 Thread Robert M. Münch via Digitalmars-d-learn
Hi, just trying to build the latest DMD with Digger 2.3 and get this: uffer.d root/port.d root/response.d root/rmem.d root/rootobject.d root/speller.d root/stringtable.d newdelete.o glue.a backend.a globals.d(293): Error: file verstr.h cannot be found or not in a path specified with -J make:

Are Lua tables possible to do with D?

2015-07-16 Thread Robert M. Münch via Digitalmars-d-learn
Hi, do you think it's possible to implemented something like Lua Tables (a hashed heterogeneous associative array) in D? I know that Lua is dynamic and interpreted, hence it's a lot simpler to do than with a compiled language but I'm wondering if we could express such a generic data-structure

Re: Are Lua tables possible to do with D?

2015-07-16 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-07-16 07:20:15 +, Fusxfaranto said: An associative array of Variant[string] ought to do the job well enough. http://dlang.org/phobos/std_variant.html Thanks a lot. Somehow didn't see that... -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: CPU cores threads fibers

2015-06-18 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-06-16 18:36:09 +, Rob T said: FYI: https://issues.dlang.org/show_bug.cgi?id=11686 https://issues.dlang.org/show_bug.cgi?id=11687 Thanks. We are currently experimenting to see how want to use the threads and what code to refactor. If we are going to bite the bullet I keep this

Re: CPU cores threads fibers

2015-06-15 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-06-14 15:54:30 +, Etienne Cimon said: Yes, however nothing really guarantees multi-threading = multi-core. The kernel reserves the right and will most likely do everything possible to keep your process core-local to use caching efficiently. Hi, sure. It's more about raising the

Re: What is D's minimum requirements on Mac?

2015-06-10 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-06-10 18:55:26 +, Adam D. Ruppe said: I'm still tempted to grab a used Mac so I can port my display stuff to Cocoa and test it, but Macs are outrageously expensive and I hate them, so want to spend as little as possible. Well, I would go at least for a 64-bit system. Otherwise

Re: CTFE enums static assert

2015-05-18 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-15 17:26:50 +, Ali Çehreli said: On 05/15/2015 09:45 AM, Robert M. Münch wrote: Is there a way I can build an ENUM from within the FOREACH? What I want to achive is, that I would like to use: final switch (myEnum) ... Sorry, I don't understand your question. :( Do you

Re: CTFE enums static assert

2015-05-15 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 18:22:17 +, Ali Çehreli said: There are many different kinds of tuples in D, only two of which I can handle: 1) Tuple from std.typecons, which are ordinarily created at run time 2) TypeTuple from std.typetuple, which are compile-time entities The documentation is not clear

Re: CTFE enums static assert

2015-05-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 22:22:51 +, ketmar said: as i said, `typeid` is runtime feature, so you can't print it with pragma. and tuples aren't exist in runtime, it's compile-time only. i think you are even more confused now. ;-) sorry. No, that makes it much more clearer for me. The compiler

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 03:52:21 +, Rikki Cattermole said: Have you looked at my book? https://leanpub.com/ctfe No, thanks for the hint. You will have one more reader ;-) -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-03 23:28:00 +, anonymous said: Here T would have to be a type. But you want to accept a string. So: template startsNotWith(string s,char c){ enum startsNotWith = s.length == 0 || s[0] != c; } Hi, ok, just to better understand this (I have a C++ background (even

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-03 23:28:00 +, anonymous said: You need to turn T into a parameter, so that StaticFilter can set it. (And it's really a string again, so I'm renaming to s.) template startsNotWithp(string s) { enum startsNotWithp = startsNotWith!(s, 'p'); } /* Shorthand syntax: enum

CTFE enums static assert

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
I find this a bit strange: // get all rules that start with p... enum BolRules = StaticFilter!(beginsWithP, __traits(allMembers,BolSource)); static assert(is(BolRules == enum)); Compiling using dmd... source/app.d(114): Error: static assert (is(BolRules == enum)) is false I'm trying to

Re: CTFE enums static assert

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 17:21:34 +, ketmar said: that's due to `enum` keyword abusing. enum type is something like this: enum MyEnum { A, B } and enum val = false; is a compile-time boolean constant, which will be inlined on using. i.e. compiler will inline such enum constants, and that

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 03:52:21 +, Rikki Cattermole said: Have you looked at my book? https://leanpub.com/ctfe I bought it. Will it be updated? It's very generic with respect the concept and I'm missing code examples for all the user-cases. Especially the generator part is IMO very interesting.

CTFE template predicates

2015-05-03 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I have now played a around couple of hours (reading everything I could find) to get something to work, but I think I'm missing some basic concepts/understanding. Maybe someone can enlighten me how these things work. I thought that some code from David Nadlinger is what I'm searching for

Re: dub -vgc

2015-05-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-01 00:52:57 +, Laeeth Isharc said: Does dflags work ? http://code.dlang.org/package-format Hi, yes. Overlooked this one as d(ebug)flags. Thanks. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

dub -vgc

2015-04-30 Thread Robert M. Münch via Digitalmars-d-learn
How can I make use of the -vgc compiler switch in my DUB project? -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: Is there something like apply?

2015-04-28 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-04-28 17:52:57 +, Adam D. Ruppe said: This can also be automated with a bit of code in a lot of cases: import std.traits; ParameterTypeTuple!foo params; foreach(index, ref param; params) { params[index] = args[index]; } foo(params); Move that into a helper function and you

Is there something like apply?

2015-04-28 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I have the following problem: I have the parameters for a function in an array. Now I want to call a function with a specific arity and use the parameters from the array to call it. Like this pseudo-code: args = [10, 20]; def foo(a, b): return a + b; print(foo(*args)); Is something

Valgrind

2015-04-20 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I just found quite old posts about Valgrind and D. Can someone give me a short update, what the state of support for D is and if there is anythings special to take into account. Thanks a lot. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

ctags

2015-04-20 Thread Robert M. Münch via Digitalmars-d-learn
Hi, is there anything for D that supports generating tags files like ctags does for C etc. ? -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: Valgrind

2015-04-20 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-04-20 13:29:57 +, John Colvin said: On Monday, 20 April 2015 at 13:28:57 UTC, John Colvin wrote: On Monday, 20 April 2015 at 13:16:23 UTC, Robert M. Münch wrote: Hi, I just found quite old posts about Valgrind and D. Can someone give me a short update, what the state of support

Re: Should this work: export extern(C) auto ...

2015-03-20 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-03-19 13:22:44 +, Benjamin Thaut said: Generally don't expect to many things to work with DLLs at the moment. Hi, well, I think what's available is good enough to get most things done. Generally speaking only exporting global functions works. Don't try to export classes /

Re: Should this work: export extern(C) auto ...

2015-03-19 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-03-18 21:50:39 +, Adam D. Ruppe said: It will not work because a function with an auto return value is actually a template, and unused templates won't be put into a dll. Ok, that makes it clear. Thanks. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: variadic mixin - the right tool for the job?

2015-03-19 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-03-18 15:27:03 +, Daniel Kozák via Digitalmars-d-learn said: You probably does not need mixins: void log(string file = __FILE__, size_t line = __LINE__, T...) (T variadic_arg) { some_fun(variadic_arg[0], file, line, variadic_arg[1 .. $]); } Hi, ha, forgot about default

variadic mixin - the right tool for the job?

2015-03-18 Thread Robert M. Münch via Digitalmars-d-learn
Hi, can something like this (I borrowed the C pre-processor idea) be done with variadic mixins? #define log(variadic-arg) sys-log(%s:%s + variadic-arg[0], __FILE__, __LINE__, variadic-arg[1..$]); I read that mixins can only be used for declarations, and this here is a function call. So

Should this work: export extern(C) auto ...

2015-03-18 Thread Robert M. Münch via Digitalmars-d-learn
Windows, 32-Bit, DLL: export extern(C) struct1 struct1(){ struct1 x; return(x); } export extern(C) auto struct2(){ struct1 x; return(x); } struct1 is visible in the DLL, struct2 is not visible in the DLL. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

<    1   2   3   4   >