Re: Tracing down core.exception.InvalidMemoryOperationError

2014-07-28 Thread Martin Drasar via Digitalmars-d-learn
On 28.7.2014 14:09, Joakim via Digitalmars-d-learn wrote: More broadly speaking, it is thrown whenever certain memory operations are attempted while the GC is running, 6 in all, as you can see here: https://github.com/D-Programming-Language/druntime/blob/master/src/gc/gc.d#L458 I believe

Re: Trouble creating bidirectional range

2013-09-30 Thread Martin Drasar
On 29.9.2013 23:19, Timon Gehr wrote: Mark 'save' with @property and it will work. Well, d'oh! It really works now, thanks Timon. And the documentation does not call it as a function anywhere. But... having save a property seems counterintuitive, at least on semantic level. Martin

Re: Trouble creating bidirectional range

2013-09-30 Thread Martin Drasar
On 30.9.2013 8:28, monarch_dodra wrote: Too late to change it now, but agreed. The new property rules mean you can easily make it a non-property and break nothing, but calling save with parrens in generic code will not be possible. I don't doubt there is a good reason, however it should be

static this () executed multiple times

2013-09-30 Thread Martin Drasar
Hi, I have a module level static this() that I thought should be executed only once per pogram run. However, in my case it is executed 13 times. Question is - is this a normal behavior that I should work with or is there something wrong going on? Thanks, Martin

Re: static this () executed multiple times

2013-09-30 Thread Martin Drasar
On 30.9.2013 18:12, Adam D. Ruppe wrote: Is your program using threads? I believe static this is run once per thread, with shared static this being the once per program one. Yup, that did the trick. Thanks. Martin

Trouble creating bidirectional range

2013-09-29 Thread Martin Drasar
Hi, I have upgraded to dmd 2.063.2 and have some troubles making my custom bidirectional range work (it used to). In fact, even this code fails on assert and I am not really sure why... import std.range; struct MyRange(T) { private: T[] data; public: T front() @property { return

Re: Trouble creating bidirectional range

2013-09-29 Thread Martin Drasar
On 29.9.2013 22:45, Andrej Mitrovic wrote: On Sunday, 29 September 2013 at 20:42:20 UTC, Andrej Mitrovic wrote: On Sunday, 29 September 2013 at 20:37:13 UTC, Martin Drasar wrote: static assert(is(typeof(tmp.save) == MyRange!string)); You should call it like this: static assert(is(typeof

Re: Question about auto ref

2013-03-29 Thread Martin Drasar
On 29.3.2013 11:59, Namespace wrote: Ok I interpret this as a rejection of the idea. This seems like a language design decision and as such would get much broader audience (and probably more responses) in digitalmars.D than in learn forum. Threads in here can get overlooked easily. Maybe you

Re: Exiting blocked threads (socket.accept)

2013-03-28 Thread Martin Drasar
On 28.3.2013 11:23, Tim wrote: Thanks Martin and Ali. Your solution works as long as I use the receive()-method, but what about using SocketStreams? I replaced socket.receive() with socketStream.readLine() which isn't broken by the solution above... If you check the documentation, you will

Re: TDPL message passing: OwnerFailed?

2013-01-22 Thread Martin Drasar
On 22.1.2013 11:08, monarch_dodra wrote: I was trying to do a simple program to test message passing. Basically, I have 1 owner, and 2 slave threads. I'm facing two problems: 1 ) First, I want the slaves to be informed of when the master dies in an abnormal way. TDPL suggest

Re: Atomic updates

2013-01-22 Thread Martin Drasar
On 22.1.2013 16:00, bearophile wrote: Do you know why the site doesn't show the ddocs here? http://dlang.org/phobos/core_atomic.html Wild guess, but couldn't it be because the ddoc documentation is inside version(CoreDdoc) and not processed? Martin

Re: Passing shared delegates

2013-01-17 Thread Martin Drasar
On 16.1.2013 22:53, Maxim Fomin wrote: Yes, it happens so (shared function made it a member). Casting away shared is UB but it can be done if your are sure. Ok. But that leaves me with an unanswered question from one of my previous posts. What happens when you cast from and to shared? Is there

Re: Passing shared delegates

2013-01-17 Thread Martin Drasar
On 17.1.2013 12:56, Maxim Fomin wrote: Casting away shared in undefined behavior. Although it may be not written explicitly in dlang.org, once D will have a standard like C or C++, it will be name like so. In practice this means that behavior of program is uncertain and may result in many

Re: Passing shared delegates

2013-01-16 Thread Martin Drasar
Okay, I have hit another thing when dealing with shared delegates. Consider this code: alias void delegate (B b) shared Callback; class A { private B _b; this (B b) { _b = b; } void callback (B b) shared { b.execute(callback); //_b.execute(callback); --

Re: Passing shared delegates

2013-01-14 Thread Martin Drasar
On 14.1.2013 8:56, Maxim Fomin wrote: Which compiler version do you use? It compiles on 2.061. It was 2.060. It compiles now on 2.061. Great! In case of applying attributes to functions, mostly it is irrelevant whether it stands first or last. So, void foo() shared {} and shared void

Re: Latest Version of Ali's Book

2012-10-11 Thread Martin Drasar
On 11.10.2012 18:17, Paul wrote: Anyone know where I can find the latest version of Ali Çehreli's D book? Thanks. Hi Paul, I thinks that the latest version is always on Ali's webpage... http://ddili.org/ders/d.en/index.html Martin

Re: Passing associative array to another thread

2012-09-22 Thread Martin Drasar
On 21.9.2012 19:01, Jacob Carlborg wrote: Perhaps declaring the associative array as shared. An alternative would be to serialize the aa, pass it to another thread, and deserialize it. That would though create a copy. Hi Jacob, thanks for the hint. Making it shared sounds a bit fishy to me.

Re: Passing associative array to another thread

2012-09-22 Thread Martin Drasar
On 22.9.2012 13:19, Jonathan M Davis wrote: The problem with immutable is probably due to this bug: http://d.puremagic.com/issues/show_bug.cgi?id=5538 And casting to shared probably won't work due to this bug: http://d.puremagic.com/issues/show_bug.cgi?id=6585 std.variant needs quite

Re: Passing associative array to another thread

2012-09-22 Thread Martin Drasar
On 22.9.2012 13:50, Johannes Pfau wrote: 1. Declare it as shared There's also __gshared. Yup, that works. Thanks

Passing associative array to another thread

2012-09-21 Thread Martin Drasar
Hi, I am using the std.concurrency module and I would like to send an associative array to another thread. If I try this: string[string] aa; someThread.send(aa); I get: Aliases to mutable thread-local data not allowed. And if I try to use this: immutable(string[string]) aa;

Task management

2012-09-14 Thread Martin Drasar
Hi, can anyone tell me what is the good (for arbitrary low values of good) way to forcibly end a running task? I am using a task pool from std.parallelism to execute delegates supplied by various plugins. As I have no real control over what gets executed and how, there is always a possibility

Re: variadic mixin templates and other stuff

2012-04-21 Thread Martin Drasar
On 20.4.2012 19:00, John Chapman wrote: On Friday, 20 April 2012 at 14:57:03 UTC, Martin Drasar wrote: On 20.4.2012 16:09, Timon Gehr wrote: I tried but it still refuses to compile: string interfaceGuid(string ifaceName) { return ifaceName ~ Guid; } mixin template EXPOSE_INTERFACES(T

variadic mixin templates and other stuff

2012-04-20 Thread Martin Drasar
Hi, I am migrating a C++ project to D and I have hit a roadblock that I hope you might help me with. My code is heavily inspired by the COM architecture, so I have naturally take a look at std/c/windows/com.d, just to find out that it does not contain all I need. In the C++ code I have several

Re: variadic mixin templates and other stuff

2012-04-20 Thread Martin Drasar
On 20.4.2012 16:09, Timon Gehr wrote: Thanks Timon for the answer. My questions are following: - can mixin templates be used this way? They can only mixin declarations. - why are they complaining? Because if is a statement and not a declaration. Ok. - is there a better way to do

Function definition in multiple modules

2012-03-29 Thread Martin Drasar
Hi, I have a class that implements a lot of interfaces and I would like to separate the definition into different files, i.e. implementation of one interface in one file. Something akin to this C++ code: a.cpp: class A { void b(); void c(); }; b.cpp: void A::b() {} c.cpp: void A::c() {}

Re: Function definition in multiple modules

2012-03-29 Thread Martin Drasar
On 29.3.2012 12:02, simendsjo wrote: Your looking for partial classes? D doesn't have this as far as I know. alias this should work for more than one value in the future, and then (I think) you should be able to do something like this: class XIB : IB {} class XIA : IA {} class X : IA, IB

Re: Function definition in multiple modules

2012-03-29 Thread Martin Drasar
On 29.3.2012 13:05, simendsjo wrote: It's not string mixins: mixin template XIA() { void a() { ... } // regular function } class X : IA { mixin XIA!() } XIA is injected into X, so X now looks like class X : IA { void a() { ... } } I should have thought and experiment more

Re: Allocating memory in D shared library when accessed from C++

2011-12-20 Thread Martin Drasar
Dne 20.12.2011 2:22, Andrej Mitrovic napsal(a): test.cpp: http://www.ideone.com/uh7vN DLibrary.d: http://www.ideone.com/fOLN8 $ g++ test.cpp $ dmd -ofDLibrary.dll DLibrary.d $ a.exe $ 9 Hi, Andrej, you are right, this works. Problem is going to be either in VisualD or cv2pdb. For those

Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Martin Drasar
Hello everyone, I would like to ask you about linking D shared objects (.dll and .so) from a C++ program. Say I have this C++ loader: typedef int (*MagicFunction) (); HMODULE handle = LoadLibraryA(DLibrary.dll); if (handle) { MagicFunction fn = (MagicFunction) GetProcAddress(handle,