Re: GC allocation

2016-04-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 April 2016 at 22:59:58 UTC, Alex wrote: Ok... I make slices of them, carefully avoiding to make copies... Yeah, that shouldn't make a difference.. Huh? I think, this is the place, where I lack some background... So, I bind my delegates via Can you post any more of your

Re: aliasing/referencing expressions in with statements

2016-04-21 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 21 April 2016 at 23:05:38 UTC, deed wrote: Often I find myself wanting to alias an expression, such as verbose fields, possibly nested. AFAIK, the with statement makes it easier, but not as good as it could have been. What I'd like to express is for example something like this:

aliasing/referencing expressions in with statements

2016-04-21 Thread deed via Digitalmars-d-learn
Often I find myself wanting to alias an expression, such as verbose fields, possibly nested. AFAIK, the with statement makes it easier, but not as good as it could have been. What I'd like to express is for example something like this: with( a = instanceA.verboseFieldA.verboseFieldB, b

Re: GC allocation

2016-04-21 Thread Alex via Digitalmars-d-learn
On Thursday, 21 April 2016 at 19:54:10 UTC, via Digitalmars-d-learn wrote: I'm on mobile so I will be brief now and expand later On Thu, Apr 21, 2016 at 07:37:59PM +, QAston via Digitalmars-d-learn wrote: Just like classes - when closure expression is executed. Heap closures are

Re: GC allocation

2016-04-21 Thread Alex via Digitalmars-d-learn
On Thursday, 21 April 2016 at 19:37:59 UTC, QAston wrote: On Thursday, 21 April 2016 at 17:27:09 UTC, Alex wrote: Ok. So, does this mean, that they just allocate on creation/binding them? If so, there is no problem and there are no questions any more. Just like classes - when closure

Re: sending shared pointer to struct. message type mismatch

2016-04-21 Thread Ali Çehreli via Digitalmars-d-learn
On 04/21/2016 02:15 PM, Steven Schveighoffer wrote: > I was unaware that a spawned thread > terminating via uncaught exception does nothing. > > It kind of makes sense, but definitely not what many would expect. In case it's useful to others, there is something written about it here:

Re: sending shared pointer to struct. message type mismatch

2016-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/21/16 1:29 PM, Steven Schveighoffer wrote: I get strange behavior. Not an error/exception, but basically hung process. I tried modifying different things, and passing other types of messages. Seems almost like the call to send is ignored for sending the s message. Nevermind, this is my

Re: GC allocation

2016-04-21 Thread via Digitalmars-d-learn
I'm on mobile so I will be brief now and expand later On Thu, Apr 21, 2016 at 07:37:59PM +, QAston via Digitalmars-d-learn wrote: > Just like classes - when closure expression is executed. Heap closures are actually allocated on declaration. The compiler looks to see if it will need to be

Re: Enabling Only Top-Level Unittests

2016-04-21 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 21 April 2016 at 12:35:42 UTC, Anonymouse wrote: Then dmd -unittest -version=TestDeps if you want them run. This doesn't make things easier. I want to disable the builtin unittests of the modules I've imported. This requires me to add a version(test_MODULE) unittest in each

Re: GC allocation

2016-04-21 Thread QAston via Digitalmars-d-learn
On Thursday, 21 April 2016 at 17:27:09 UTC, Alex wrote: Ok. So, does this mean, that they just allocate on creation/binding them? If so, there is no problem and there are no questions any more. Just like classes - when closure expression is executed. I have an unusual caption... On creation

Re: Adding a float with all four elements of a float4

2016-04-21 Thread Marco Leise via Digitalmars-d-learn
Am Thu, 21 Apr 2016 00:14:53 + schrieb Straivers : > Hi, > > I want to make a utility wrapper around a core.simd.float4, and > have been trying to make the following code work, but have been > met with no success. > > auto add(float rhs) > { > return

Re: sending shared pointer to struct. message type mismatch

2016-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/21/16 1:33 PM, ag0aep6g wrote: This creates a `shared(S!(M, 2))*`, which is not exactly the same as `shared(S!(M, 2)*)`. The pointer is not shared in the former, but it is shared in the latter. I was going to suggest either sending a `shared(TS*)` or receiving a `shared(T)*`. But it looks

Re: sending shared pointer to struct. message type mismatch

2016-04-21 Thread jacob via Digitalmars-d-learn
On Thursday, 21 April 2016 at 17:33:32 UTC, ag0aep6g wrote: On 21.04.2016 19:10, jacob wrote: I was going to suggest either sending a `shared(TS*)` or receiving a `shared(T)*`. But it looks like you can't send a shared pointer. When I tried, it got turned into a unshared-pointer-to-shared on

Re: sending shared pointer to struct. message type mismatch

2016-04-21 Thread ag0aep6g via Digitalmars-d-learn
On 21.04.2016 19:10, jacob wrote: private void runner(T)() { shared(T*) s = receiveOnly!(shared(T*))(); This tries to receive a `shared(S!(M, 2)*)`. writeln(s.x.length); writeln(s.x[0]); send(thisTid, true); Aside: Should be `ownerTid` here, no? } int main(string[]

Re: sending shared pointer to struct. message type mismatch

2016-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/21/16 1:10 PM, jacob wrote: import std.stdio; import std.concurrency; shared struct S(T, uint M) { T[M] x; } shared struct M { int x; } private void runner(T)() { shared(T*) s = receiveOnly!(shared(T*))(); writeln(s.x.length); writeln(s.x[0]); send(thisTid,

Re: GC allocation

2016-04-21 Thread Alex via Digitalmars-d-learn
On Thursday, 21 April 2016 at 15:44:56 UTC, QAston wrote: Closure (delegate type) objects have to allocate because they're reference types and have state. For stateful reference types to be safe they have to be put on the GC allocated heap. Ok. So, does this mean, that they just allocate on

sending shared pointer to struct. message type mismatch

2016-04-21 Thread jacob via Digitalmars-d-learn
Hello! I try to send shared pointer to struct: [code] import std.stdio; import std.concurrency; shared struct S(T, uint M) { T[M] x; } shared struct M { int x; } private void runner(T)() { shared(T*) s = receiveOnly!(shared(T*))(); writeln(s.x.length);

Re: Instantiate!(Template, args) in Phobos?

2016-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/21/16 10:47 AM, Nick Treleaven wrote: Hi, There doesn't seem to be something like this in Phobos: alias Instantiate(alias Template, T...) = Template!T; Here's an example of why I need it: alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) =

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread rcorre via Digitalmars-d-learn
On Thursday, 21 April 2016 at 12:57:36 UTC, Rene Zwanenburg wrote: On Thursday, 21 April 2016 at 11:54:27 UTC, rcorre wrote: Thanks for the tip. Here's the linking code it shows: cc d.o -o d -m64 -L/usr/lib -L/usr/lib32 -Xlinker --export-dynamic -Xlinker -Bstatic -lphobos2 -Xlinker

Re: VariantPointer

2016-04-21 Thread Lass Safin via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 20:07:31 UTC, Nordlöw wrote: On Wednesday, 20 April 2016 at 16:08:32 UTC, Lass Safin wrote: core.memory.GC.setAttr can set attributes for a block of memory, with which you can set the attribute NO_SCAN, which as it implies, forces that no scan be done in the

Re: Using D in Android App

2016-04-21 Thread Vadim Lopatin via Digitalmars-d-learn
On Saturday, 16 April 2016 at 04:04:24 UTC, Justice wrote: Is it difficult to create a D business like app and connect it to android through java for the interface? I'd rather create all the complex stuff in D and either use it natively through java(I need a UI). If it is workable, can the

Re: GC allocation

2016-04-21 Thread QAston via Digitalmars-d-learn
On Thursday, 21 April 2016 at 15:22:15 UTC, Alex wrote: Hi all! timing my program with valgrind/cachegrind and using -vgc option of the compiler found the message: "using closure causes GC allocation" The question is: does the usage of the closure causes the GC allocation on every usage of

GC allocation

2016-04-21 Thread Alex via Digitalmars-d-learn
Hi all! timing my program with valgrind/cachegrind and using -vgc option of the compiler found the message: "using closure causes GC allocation" The question is: does the usage of the closure causes the GC allocation on every usage of the closure or only on creation/assigning of it? If the

Instantiate!(Template, args) in Phobos?

2016-04-21 Thread Nick Treleaven via Digitalmars-d-learn
Hi, There doesn't seem to be something like this in Phobos: alias Instantiate(alias Template, T...) = Template!T; Here's an example of why I need it: alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) = Instantiate!(.staticEx!(Exception, msg), file, line);

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 21 April 2016 at 11:54:27 UTC, rcorre wrote: Thanks for the tip. Here's the linking code it shows: cc d.o -o d -m64 -L/usr/lib -L/usr/lib32 -Xlinker --export-dynamic -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl /usr/bin/ld: d.o: relocation R_X86_64_32

Re: Enabling Only Top-Level Unittests

2016-04-21 Thread Anonymouse via Digitalmars-d-learn
On Monday, 21 March 2016 at 10:29:36 UTC, Nordlöw wrote: I want to enable unittests only at the top-level of a module compilation. If I have a module top.d that imports dep1.d dep2.d ... which all contain unittests, how do I compile top.d with only the unittests for top.d

Re: Enabling Only Top-Level Unittests

2016-04-21 Thread Nordlöw via Digitalmars-d-learn
On Monday, 21 March 2016 at 15:25:29 UTC, Adam D. Ruppe wrote: Yes, compiling 33,000 lines from my libs happened in about one second. My experience with slow D builds tends to be that it is caused by CTFE, not by scale. These kinds of modules are very different from the ones I'm working

Re: Shallow copy object when type is know

2016-04-21 Thread rumbu via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 12:32:48 UTC, Tofu Ninja wrote: Is there a way to shallow copy an object when the type is known? I cant seem to figure out if there is a standard way. I can't just implement a copy function for the class, I need a generic solution. extern (C) Object

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread rcorre via Digitalmars-d-learn
On Thursday, 21 April 2016 at 09:55:30 UTC, Rene Zwanenburg wrote: On Thursday, 21 April 2016 at 01:20:27 UTC, rcorre wrote: s/compile/link I _can_ compile a D library, but as soon as I try to link anything compiled with DMD it falls over. What is dmd's verbose output? (add -v switch) Some

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:20:27 UTC, rcorre wrote: s/compile/link I _can_ compile a D library, but as soon as I try to link anything compiled with DMD it falls over. What is dmd's verbose output? (add -v switch) Some of the things it outputs are the location of the config file it

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread Chris via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:20:27 UTC, rcorre wrote: s/compile/link I _can_ compile a D library, but as soon as I try to link anything compiled with DMD it falls over. Sorry, I didn't see the code in your first post. I tried it myself (in only have 2.070.2) and it worked fine. Have

Re: Shallow copy object when type is know

2016-04-21 Thread Marc Schütz via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 19:58:15 UTC, Tofu Ninja wrote: How does D not have shallow copy? Seems like a very basic functionality... You could implement a `dup()` method. `dup` is already used for shallow copying of arrays, why not reuse it for classes (as a convention)?

Re: Shallow copy object when type is know

2016-04-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 19:58:15 UTC, Tofu Ninja wrote: To implement a copy/paste/duplicate functionality in a game editor. I have an entity-component system, to duplicate an entity, all it's components need to be duplicated. I have many many components, I don't want to rely on manually