Re: Choice ranges?

2014-03-29 Thread H. S. Teoh
> On 03/28/2014 08:00 PM, H. S. Teoh wrote: > >Today I ran into an interesting situation where I have a function f > >that needs to return ranges of different types (but identical element > >types): > > > > auto f(A...)(A args) { > > ... > > if (someCondition) > >

Re: Wrapping C code?

2014-03-29 Thread anonymous
On Saturday, 29 March 2014 at 21:30:03 UTC, CJS wrote: Well, you can write one. You can also let D generate that list: __traits(allMembers, some_c_module) gives you all symbols in some_c_module. [...] I don't understand how that is possible. The C code I have available is a compiled library and

Re: Wrapping C code?

2014-03-29 Thread CJS
Well, you can write one. You can also let D generate that list: __traits(allMembers, some_c_module) gives you all symbols in some_c_module. Iterate over them, generate alias declarations, mix those declarations in. I don't understand how that is possible. The C code I have available is a comp

Re: Order of destruction of local variables

2014-03-29 Thread Marc Schütz
On Friday, 28 March 2014 at 21:10:39 UTC, Ali Çehreli wrote: On 03/28/2014 12:03 PM, "Marc Schütz" " wrote: > destruction happens in reverse lexical order of declaration, > and arrays are destroyed from back to front. > > Is this behaviour guaranteed? It must be that way because later objects c

Re: Wrapping C code?

2014-03-29 Thread anonymous
On Saturday, 29 March 2014 at 19:25:37 UTC, CJS wrote: When you say define them in bulk at compile time, is there some convenient way to just give an array of actions and iterate over them to generate such statements? So that the only work that needs to be updated to add/remove actions is updat

Re: Wrapping C code?

2014-03-29 Thread bearophile
CJS: When you say define them in bulk at compile time, is there some convenient way to just give an array of actions and iterate over them to generate such statements? So that the only work that needs to be updated to add/remove actions is updating that list? You also need extern(C). So the

Re: Wrapping C code?

2014-03-29 Thread CJS
On Saturday, 29 March 2014 at 19:16:34 UTC, bearophile wrote: alias context = action; Sorry, I meant: alias action = action; Bye, bearophile When you say define them in bulk at compile time, is there some convenient way to just give an array of actions and iterate over them to gen

Re: Wrapping C code?

2014-03-29 Thread Artur Skawina
On 03/29/14 20:01, CJS wrote: > I've been using a medium-sized C library. Most of the library calls look > something like > > action(context, arg1, arg2) > > Where is the name of the library, action is the action to take, and > context is an opaque pointer defined by the library to kee

Re: Wrapping C code?

2014-03-29 Thread bearophile
CJS: I've been using a medium-sized C library. Most of the library calls look something like action(context, arg1, arg2) Where is the name of the library, action is the action to take, and context is an opaque pointer defined by the library to keep all the state related to these ac

Re: Wrapping C code?

2014-03-29 Thread bearophile
alias context = action; Sorry, I meant: alias action = action; Bye, bearophile

Wrapping C code?

2014-03-29 Thread CJS
I've been using a medium-sized C library. Most of the library calls look something like action(context, arg1, arg2) Where is the name of the library, action is the action to take, and context is an opaque pointer defined by the library to keep all the state related to these actions.

Re: Choice ranges?

2014-03-29 Thread Artur Skawina
On 03/29/14 18:30, Timon Gehr wrote: > > I'm stuck with 2.060 myself, but there's always http://dpaste.dzfl.pl/. For the examples, I used a gdc that claims __VERSION__==2062L. (for /real/ code I'm still using a 2.057 based one...) artur

Re: Choice ranges?

2014-03-29 Thread Timon Gehr
On 03/29/2014 06:19 PM, Artur Skawina wrote: Of course it compiles -- with the compiler version I happen to use... The compiler situation is one of the main reasons I gave up on D about a year ago. Every release introduces a new dialect. This may not be such a big problem for trivial toy program

Re: Choice ranges?

2014-03-29 Thread Artur Skawina
On 03/29/14 16:31, Timon Gehr wrote: > On 03/29/2014 01:37 AM, Artur Skawina wrote: >> You can wrap the range in a common one. When the above approach isn't >> enough, there's always the next level: > > (Note that your code does not actually compile.) Of course it compiles -- with the compiler ve

Re: Choice ranges?

2014-03-29 Thread Timon Gehr
On 03/29/2014 01:37 AM, Artur Skawina wrote: You can wrap the range in a common one. When the above approach isn't enough, there's always the next level: (Note that your code does not actually compile.)

Re: Choice ranges?

2014-03-29 Thread Timon Gehr
On 03/28/2014 08:00 PM, H. S. Teoh wrote: Today I ran into an interesting situation where I have a function f that needs to return ranges of different types (but identical element types): auto f(A...)(A args) { ... if (someCondition)

Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-29 Thread BeschBesch
I want to use a set of functions that rely on a library which is not available for D (Harfbuzz). So I just wrote myself a set a functions that will do anything I need (Init, Free, Fonts, Text, etc). The DLL is working fine and dynamically linking should work (it does in C++ --> LoadLibrary).

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-29 Thread BeschBesch
extern (C) /// needed so the compiler can link the functions { void Test(); } The function of course is called "Test1" not Test.