COM Expertise needed: COM Callbacks

2017-04-23 Thread Nierjerson via Digitalmars-d-learn
Still trying to get the com automation code working. This is a general issue with COM programming as I do not have the experience to solve the problem. There are two files at: http://s000.tinyupload.com/index.php?file_id=33201858563271816000 Gen.d is the automatically generated COM wrapper in

Re: using shared effectively in a producer/consumer situation.

2017-04-23 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:33:48 UTC, Kevin Balbas wrote: I guess the follow up here is: Is this the correct way to do it? cast to shared, send to main thread, cast away shared? At the moment, pretty much yes. Either that or make the (unnecessary) immutable copies. There are no ownersh

Re: function type parameter inference not working

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Sunday, 23 April 2017 at 19:40:39 UTC, ag0aep6g wrote: Please post self-contained code. When I fill the gaps you left, it works for me: Interesting, thanks a lot. I'll test and narrow down what's in my code preventing this from working (I can't really think of anything) and I'll report b

Re: Get name of current function

2017-04-23 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:34:12 UTC, Mike B Johnson wrote: I'd like to get the symbolic name of the current function I'm in void foo() { writeln(thisFunc.stringof()); // prints foo } I need something short, elegant and doesn't require modifying preexisting code... I'm sure D has somet

Re: Get name of current function

2017-04-23 Thread cym13 via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:34:12 UTC, Mike B Johnson wrote: I'd like to get the symbolic name of the current function I'm in void foo() { writeln(thisFunc.stringof()); // prints foo } I need something short, elegant and doesn't require modifying preexisting code... I'm sure D has somet

Re: Get name of current function

2017-04-23 Thread Mike Wey via Digitalmars-d-learn
On 04/23/2017 10:34 PM, Mike B Johnson wrote: I'd like to get the symbolic name of the current function I'm in void foo() { writeln(thisFunc.stringof()); // prints foo } I need something short, elegant and doesn't require modifying preexisting code... I'm sure D has something along those

Get name of current function

2017-04-23 Thread Mike B Johnson via Digitalmars-d-learn
I'd like to get the symbolic name of the current function I'm in void foo() { writeln(thisFunc.stringof()); // prints foo } I need something short, elegant and doesn't require modifying preexisting code... I'm sure D has something along those lines?

Re: using shared effectively in a producer/consumer situation.

2017-04-23 Thread Kevin Balbas via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:30:33 UTC, Kevin Balbas wrote: I have an application where a long-lived "loader" thread takes messages to load data, loads that data, and then sends it back to the main thread via the standard concurrency primitives. Something like this: void threadFunc(Tid own

using shared effectively in a producer/consumer situation.

2017-04-23 Thread Kevin Balbas via Digitalmars-d-learn
I have an application where a long-lived "loader" thread takes messages to load data, loads that data, and then sends it back to the main thread via the standard concurrency primitives. Something like this: void threadFunc(Tid ownerTid) { while(true) { receive( (in

Re: function type parameter inference not working

2017-04-23 Thread ag0aep6g via Digitalmars-d-learn
On 04/23/2017 09:33 PM, XavierAP wrote: void assembleMass1D(Mat, Vec)(ref Mat M, const ref Vec x) { /* ... */ } Matrix!(2,2) M = /* ... */; Vector!2 V = /* ... */; assembleMass1D(M, V); // ERROR template cannot deduce function from argument types Please post self-contained code. When I fill

function type parameter inference not working

2017-04-23 Thread XavierAP via Digitalmars-d-learn
It's not working for my case, while I see no special reason why it couldn't. Also I can't find specific inference rules at http://dlang.org/spec/function.html#function-templates Is it a problem that the types to be inferred are in turn also templated? Any workaround that can make inference wor

Re: multi-dimensional array whole slicing

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Sunday, 23 April 2017 at 09:06:35 UTC, Ali Çehreli wrote: It took me a while to convince myself that there is no bug here. The problem, as is obvious to others, ;) a whole slice of a whole slice is still the same slice. Ha, you're right, I hadn't realized. But I still have a problem. For

Re: Binding a udp socket to a port(on the local machine)

2017-04-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 22 April 2017 at 21:24:33 UTC, Chainingsolid wrote: I couldn't figure out how to make a udp socket bound to a port of my choosing on the local machine, to use for listening for incoming connections. I assume you meant "incoming datagrams" and not "incoming connections". import

Re: Output-Range and char

2017-04-23 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 23 April 2017 at 11:17:37 UTC, Mafi wrote: Hi there, every time I want to use output-ranges again they seem to be broken in a different way (e.g. value/reference semantics). This time it is char types and encoding. [...] Use sformat: import std.format, std.stdio; void main() {

Re: Output-Range and char

2017-04-23 Thread Mafi via Digitalmars-d-learn
On Sunday, 23 April 2017 at 12:03:58 UTC, Ali Çehreli wrote: On 04/23/2017 04:17 AM, Mafi wrote: /opt/compilers/dmd2/include/std/range/primitives.d(351): Error: static assert "Cannot put a char into a char[]." Appender recommended: import std.format, std.stdio, std.array; void main() {

Re: Output-Range and char

2017-04-23 Thread Ali Çehreli via Digitalmars-d-learn
On 04/23/2017 04:17 AM, Mafi wrote: /opt/compilers/dmd2/include/std/range/primitives.d(351): Error: static assert "Cannot put a char into a char[]." Appender recommended: import std.format, std.stdio, std.array; void main() { auto sink = appender!(char[])(); formattedWrite(sink, "Lo

Output-Range and char

2017-04-23 Thread Mafi via Digitalmars-d-learn
Hi there, every time I want to use output-ranges again they seem to be broken in a different way (e.g. value/reference semantics). This time it is char types and encoding. How do I make formattedWrite work with a char buffer? I tried the following code and it fails with a *static assert*; it

Re: multi-dimensional array whole slicing

2017-04-23 Thread Ali Çehreli via Digitalmars-d-learn
On 04/22/2017 01:51 PM, XavierAP wrote: > I can do: > > int[3] arr = void; > arr[] = 1; > > But apparently I can't do: > > int[3][4] arr = void; > arr[][] = 1; > > What is the best way? What am I missing? It took me a while to convince myself that there is no bug here. The problem, as is obvious

Re: multi-dimensional array whole slicing

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Saturday, 22 April 2017 at 22:25:58 UTC, kinke wrote: int[3][4] arr = void; (cast(int[]) arr)[] = 1; assert(arr[3][2] == 1); Thanks... I think I prefer to write two loops though :p I wish D built-in arrays supported [,] indexing notation like C# (or as you can do in D for custom types)