Re: Why using wrappers for D?

2016-10-03 Thread Kagamin via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:08:54 UTC, Chalix wrote: Hi All! The documentation of D (https://dlang.org/overview.html#compatibility) says: "Direct Access to C API's Not only does D have data types that correspond to C types, it provides direct access to C functions. There is no need to

Re: Why using wrappers for D?

2016-10-03 Thread rikki cattermole via Digitalmars-d-learn
On 04/10/2016 1:56 AM, Chalix wrote: On Monday, 3 October 2016 at 12:15:10 UTC, rikki cattermole wrote: To use any kind of function you must declare it, plain and simple. Any c or c++ function/class is the very much same way. Now C++ types such as classes are highly limited in D since it

Re: Getting consistent behavour for class properties

2016-10-03 Thread Kagamin via Digitalmars-d-learn
I suppose that's https://issues.dlang.org/show_bug.cgi?id=8006

Re: Why using wrappers for D?

2016-10-03 Thread Kagamin via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:47:48 UTC, Chalix wrote: Also, I used the Qt library a lot with C++. But although it is a library, I have access to all the classes, like " QWidget w = new QWidget();". There is no factory method used. (This confuses me now a bit...) Qt bindings is a major

Re: Why using wrappers for D?

2016-10-03 Thread Kagamin via Digitalmars-d-learn
On Monday, 3 October 2016 at 13:12:55 UTC, Chalix wrote: But I don't get, why I have a gtkd-3 lib. Why can't I just link against the gtk-3 lib then? I have now the headers to use the nice D stuff, but the linking should be done against the C-compiled library. If you don't use D-specific

Re: Why using wrappers for D?

2016-10-03 Thread Mike Parker via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:08:54 UTC, Chalix wrote: Furthermore, if there is an not very popular C library, where no wrapper function exists, would it possible to include it into a D project? Probably I have to transform all the .h to .d files, so i can "import" them instead of "include"

Re: Why using wrappers for D?

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:54:03 UTC, Adam D. Ruppe wrote: It is possible, you just need to match compilers with the library in C++, whereas C libraries don't need such an exact match. With your Qt library, you get a build of it that is compatible with the compiler you use to build your

Re: Why using wrappers for D?

2016-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 03, 2016 17:19:47 Chalix via Digitalmars-d-learn wrote: > But there still is one thing, which I don't get: > > If I "import foo;" in my project, it will be compiled alongside. > So there is no need for an extra library. Same should be for > wrapfoo.d. If I "import wrapfoo;", I

Re: Why using wrappers for D?

2016-10-03 Thread Ali Çehreli via Digitalmars-d-learn
On 10/03/2016 05:47 AM, Chalix wrote: > what do you mean > by "turn C functions into classes"? Many C APIs are object-oriented in that, they pass the most interesting object as the first parameter: // C struct struct Foo { // ... }; // Factory method (or, "constructor") Foo*

Re: Why using wrappers for D?

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Monday, 3 October 2016 at 17:56:46 UTC, ag0aep6g wrote: When you do precompile to a library, you can skip the compilation later. That can save time. True, linking with this library instead of compiling it every time I changed my code will save me a lot of time :)

Re: Why using wrappers for D?

2016-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 03, 2016 18:05:47 Chalix via Digitalmars-d-learn wrote: > Ah great, now I understand it :) > I thought, import and include would work the same way (taking all > the code in the .h or .d file and pasting it into the other file). > But if import extracts only the definitions, it

Re: Why using wrappers for D?

2016-10-03 Thread Mike Parker via Digitalmars-d-learn
On Monday, 3 October 2016 at 17:19:47 UTC, Chalix wrote: If I "import foo;" in my project, it will be compiled alongside. So there is no need for an extra library. Same should be for wrapfoo.d. If I "import wrapfoo;", I should just need the C-library "foo", and no D-library "food" right?

Re: Why using wrappers for D?

2016-10-03 Thread ag0aep6g via Digitalmars-d-learn
On 10/03/2016 07:19 PM, Chalix wrote: If I "import foo;" in my project, it will be compiled alongside. Not necessarily. dmd won't compile foo unless you tell it to by putting foo.d on the command line. If foo is only imported, dmd parses the file but it doesn't compile it. So there is no

Re: Getting GtkD working with OpenGL

2016-10-03 Thread Mike Wey via Digitalmars-d-learn
On 10/03/2016 01:50 PM, Chalix wrote: On Sunday, 18 September 2016 at 21:41:45 UTC, Mike Wey wrote: The demo still uses the old GtkGLExt binding, which usually isn't available in de distributions repositories. The newer GLArea is easier to use since it's part of GTK. As for the linker errors,

Re: Why using wrappers for D?

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Monday, 3 October 2016 at 17:45:55 UTC, Jonathan M Davis wrote: The import statement just tells the D compiler to pull in declarations for the symbols that it needs from those modules. It doesn't actually compile those modules. You still have to give them to the compiler (either all

Re: Why using wrappers for D?

2016-10-03 Thread Mike Wey via Digitalmars-d-learn
On 10/03/2016 07:19 PM, Chalix wrote: On Monday, 3 October 2016 at 13:51:28 UTC, Mike Parker wrote: // wrapfoo.d import foo; // import the foo module from above void myFunc(string s) { import std.string : toStringz; my_func(s.toStringz()); } Thank you for the example, Mike! And

Re: Why using wrappers for D?

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Monday, 3 October 2016 at 13:51:28 UTC, Mike Parker wrote: // wrapfoo.d import foo; // import the foo module from above void myFunc(string s) { import std.string : toStringz; my_func(s.toStringz()); } Thank you for the example, Mike! And thanks to all others who support me with

Re: How to make rsplit (like in Python) in D

2016-10-03 Thread Uranuz via Digitalmars-d-learn
On Saturday, 1 October 2016 at 18:33:02 UTC, TheFlyingFiddle wrote: On Saturday, 1 October 2016 at 16:45:11 UTC, Uranuz wrote: [...] There are two reasons why this does not compile. The first has to do with how retro() (and indeed most function in std.range) work with utf-8 strings (eg the

Re: How to make rsplit (like in Python) in D

2016-10-03 Thread Uranuz via Digitalmars-d-learn
On Saturday, 1 October 2016 at 18:55:54 UTC, pineapple wrote: On Saturday, 1 October 2016 at 17:55:08 UTC, Uranuz wrote: On Saturday, 1 October 2016 at 17:32:59 UTC, Uranuz wrote: On Saturday, 1 October 2016 at 17:23:16 UTC, Uranuz wrote: [...] But these example fails. Oops. Looks like a

Re: How to make rsplit (like in Python) in D

2016-10-03 Thread pineapple via Digitalmars-d-learn
On Monday, 3 October 2016 at 19:25:59 UTC, Uranuz wrote: When I pass empty string to splitter in most of languages I expect to get list with 1 item (empty string) as a result, but I get error instead. And I see inconsistency in that .front behaves normally, but .back is not. Usually I access

Re: Getting GtkD working with OpenGL

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Monday, 3 October 2016 at 18:00:53 UTC, Mike Wey wrote: The signal functions can be found in the gobject.Signals module. But you should use the GLArea.addOnCreateContext / addOnRender / addOnResize functions to attach a D delegate to the signal. You will still need to link with the OpenGL

Re: Class attributes

2016-10-03 Thread Satoshi via Digitalmars-d-learn
On Sunday, 2 October 2016 at 17:22:57 UTC, Basile B. wrote: On Sunday, 2 October 2016 at 15:54:38 UTC, Satoshi wrote: Hello, why pure @safe nothrow @nogc struct Point { } isn't same as struct Point { pure: @safe: nothrow: @nogc: } ?? This is not specified but attributes aren't applied to

Re: Usage of DDOC_KEYWORD and DDOC_TEMPLATE_PARAM macros

2016-10-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-09-27 22:21, Jacob Carlborg wrote: I'm working on a Ddoc theme and I have trouble figuring out when the DDOC_KEYWORD and DDOC_TEMPLATE_PARAM macros are used. Are the compiler outputting them or should the developer be using those directly? If the compiler is outputting them, then when is

Re: How to debug (potential) GC bugs?

2016-10-03 Thread Kagamin via Digitalmars-d-learn
On Saturday, 1 October 2016 at 00:06:05 UTC, Matthias Klumpp wrote: I do none of those things in my code though... `grep "~this" *.d` gives nothing? It can be a struct with destructor stored in a class. Can you observe the error? Try to set a breakpoint at onInvalidMemoryOperationError

Re: dmd -o- option meaning changed recently? Now not creating OBJ but also not creating EXE

2016-10-03 Thread Dicebot via Digitalmars-d-learn
On Sunday, 2 October 2016 at 21:05:25 UTC, A D dev wrote: One last point: If that was always the behavior (in all versions from 2010 - or earlier), i.e. -o- generates neither .OBJ nor .EXE, then what is the purpose of the option? does it act as just a syntax check? Purpose is to skip code

Re: How to debug (potential) GC bugs?

2016-10-03 Thread Kagamin via Digitalmars-d-learn
On Sunday, 25 September 2016 at 16:23:11 UTC, Matthias Klumpp wrote: For Ubuntu, some modifications on the code were needed, and apparently for them the code is currently crashing in the GC collection thread: http://paste.debian.net/840490/ Oh, wait, what do you mean by crashing?

Re: How to debug (potential) GC bugs?

2016-10-03 Thread Kagamin via Digitalmars-d-learn
If it's heap corruption, GC has debugging option -debug=SENTINEL - for buffer overrun checks. Also that particular stack trace shows that object being destroyed is allocated in bin 512, i.e. its size is between 256 and 512 bytes.

Re: Implicit casting of int enum members to int

2016-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 02, 2016 18:31:11 Mike Bierlee via Digitalmars-d-learn wrote: > Consider the following code: > > enum StringTypeEnumOne : string { > bla = "bla" > } > > enum StringTypeEnumTwo : string { > bleh = "bleh" > } > > enum IntTypeEnumOne : int { > bla = 1 > } > > enum

vibe.d Logger

2016-10-03 Thread Chris via Digitalmars-d-learn
Is this the preferred logging module for vibe.d: http://vibed.org/api/vibe.core.log/ There is also: http://vibed.org/api/vibe.http.log/ which is there for backwards compatibility?

bug, or is this also intended?

2016-10-03 Thread deed via Digitalmars-d-learn
Unexpected auto-concatenation of string elements: string[] arr = ["a", "b" "c"];// ["a", "bc"], length==2 int[] arr2 = [[1], [2] [3]];// Error: array index 3 is out of bounds [2][0 .. 1] // Error: array index 3 is out of bounds [0..1] dmd

Re: bug, or is this also intended?

2016-10-03 Thread ag0aep6g via Digitalmars-d-learn
On 10/03/2016 01:40 PM, deed wrote: Unexpected auto-concatenation of string elements: string[] arr = ["a", "b" "c"];// ["a", "bc"], length==2 int[] arr2 = [[1], [2] [3]];// Error: array index 3 is out of bounds [2][0 .. 1] // Error: array index 3 is

Why using wrappers for D?

2016-10-03 Thread Chalix via Digitalmars-d-learn
Hi All! The documentation of D (https://dlang.org/overview.html#compatibility) says: "Direct Access to C API's Not only does D have data types that correspond to C types, it provides direct access to C functions. There is no need to write wrapper functions, parameter swizzlers, nor code to

Re: Why using wrappers for D?

2016-10-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:08:54 UTC, Chalix wrote: So, if there is no need for wrapper functions, why are there a lot of them? A lot of people like the wrappers as being prettier to use since you can turn C functions into classes and such. gtkd is an example of that. Furthermore, if

Re: vibe.d Logger

2016-10-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-10-03 12:36, Chris wrote: Is this the preferred logging module for vibe.d: http://vibed.org/api/vibe.core.log/ There is also: http://vibed.org/api/vibe.http.log/ which is there for backwards compatibility? The second one is specific for HTTP. The first one is generic. -- /Jacob

Re: Getting GtkD working with OpenGL

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Sunday, 18 September 2016 at 21:41:45 UTC, Mike Wey wrote: The demo still uses the old GtkGLExt binding, which usually isn't available in de distributions repositories. The newer GLArea is easier to use since it's part of GTK. As for the linker errors, you'll need to link with the OpenGL

Re: Why using wrappers for D?

2016-10-03 Thread rikki cattermole via Digitalmars-d-learn
On 04/10/2016 1:08 AM, Chalix wrote: Hi All! The documentation of D (https://dlang.org/overview.html#compatibility) says: "Direct Access to C API's Not only does D have data types that correspond to C types, it provides direct access to C functions. There is no need to write wrapper

Re: Why using wrappers for D?

2016-10-03 Thread cym13 via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:08:54 UTC, Chalix wrote: Hi All! The documentation of D (https://dlang.org/overview.html#compatibility) says: "Direct Access to C API's Not only does D have data types that correspond to C types, it provides direct access to C functions. There is no need to

Re: Why using wrappers for D?

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:12:44 UTC, Adam D. Ruppe wrote: A lot of people like the wrappers as being prettier to use since you can turn C functions into classes and such. gtkd is an example of that. Thanks for your fast answers :) Hm, I thing I am missing some fundamentals... I read a

Re: Why using wrappers for D?

2016-10-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:47:48 UTC, Chalix wrote: I read a bit about creating libraries in C++, and I found out, this is not possible, because there is no definition of the API. It is possible, you just need to match compilers with the library in C++, whereas C libraries don't need

Re: Why using wrappers for D?

2016-10-03 Thread Chalix via Digitalmars-d-learn
On Monday, 3 October 2016 at 12:15:10 UTC, rikki cattermole wrote: To use any kind of function you must declare it, plain and simple. Any c or c++ function/class is the very much same way. Now C++ types such as classes are highly limited in D since it doesn't ugh cross over all that well (it