Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn
On Friday, 24 November 2017 at 05:01:17 UTC, Basile B. wrote: On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote: On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include'

Re: betterC and noboundscheck

2017-11-23 Thread Basile B. via Digitalmars-d-learn
On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote: On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include' -noboundscheck flag? It's bug or in some cases it's useful?

Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include' -noboundscheck flag? It's bug or in some cases it's useful? Interestingly, ldc2 will compile this ok, without the -noboundscheck

Re: reduce condition nesting

2017-11-23 Thread Michael via Digitalmars-d-learn
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana wrote: On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe wrote: On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: for instance in kotlin it can be replace with this: when { c1 -> foo(), c2 -> bar(),

Re: reduce condition nesting

2017-11-23 Thread Temtaime via Digitalmars-d-learn
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana wrote: On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe wrote: On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: for instance in kotlin it can be replace with this: when { c1 -> foo(), c2 -> bar(),

Re: GUI program on Mac OS in D?

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-23 17:06, Adam D. Ruppe wrote: I know we have the extern(Objective-C) stuff from https://wiki.dlang.org/DIP43 now, but do we have existing bindings anywhere along the lines of the win32 ones we can just import and start calling the operating system functions? Not as far as I know.

Re: reduce condition nesting

2017-11-23 Thread drug via Digitalmars-d-learn
23.11.2017 17:16, Andrea Fontana пишет: On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe wrote: On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: for instance in kotlin it can be replace with this: when {     c1 -> foo(),     c2 -> bar(),     c3 -> ...     else ->

Re: GUI program on Mac OS in D?

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2017 at 16:14:50 UTC, Guillaume Piolat wrote: Perhaps https://github.com/p0nce/DerelictCocoa Well, that would be one option, though I was hoping to avoid the extern(C) runtime stuff and dynamic loading - ideally, I want something with the extern(Objective-C) stuff

Re: Mirroring a drawable buf in DLangUI?

2017-11-23 Thread Dukc via Digitalmars-d-learn
On Thursday, 23 November 2017 at 13:31:23 UTC, Vadim Lopatin wrote: There is no such feature currently, but it can be added easy. In the meantime I should call OpenGL (I think it's the backend in my case) directly, correct?

Re: GUI program on Mac OS in D?

2017-11-23 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 23 November 2017 at 16:06:28 UTC, Adam D. Ruppe wrote: I know we have the extern(Objective-C) stuff from https://wiki.dlang.org/DIP43 now, but do we have existing bindings anywhere along the lines of the win32 ones we can just import and start calling the operating system

GUI program on Mac OS in D?

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
I know we have the extern(Objective-C) stuff from https://wiki.dlang.org/DIP43 now, but do we have existing bindings anywhere along the lines of the win32 ones we can just import and start calling the operating system functions? Moreover, I'm not a Mac dev; I've never actually done so much of

Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Timoses via Digitalmars-d-learn
On Thursday, 23 November 2017 at 15:45:17 UTC, Rene Zwanenburg wrote: On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote: A aaa = a; That's initialization, not assignment, which is subtly different. It will call the postblit on aaa instead of opAssign. A postblit can be

Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote: A aaa = a; That's initialization, not assignment, which is subtly different. It will call the postblit on aaa instead of opAssign. A postblit can be defined this way: this(this) { } There is no way to access the original a

Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote: A member; this(A a) { this.member = a; // specifically aiming towards this assignment... That's not assignment, that's construction. opAssign is only called when you assign over a struct object that already

Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Timoses via Digitalmars-d-learn
On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote: I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated which is a great idea for safe inter-thread communication. Are there any more usage examples for vibe's worker tasks that show how to send instances of

opAssign for most struct assignment calls not executed

2017-11-23 Thread Timoses via Digitalmars-d-learn
What am I missing? import std.stdio; struct A { int value; A opAssign(A a) { writeln(" Assigning"); return this; // I know this makes little sense, just for illustration } } class B { A member; this(A a) { this.member = a; //

Re: Decimal handling for currency (precision)

2017-11-23 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 23 November 2017 at 14:47:21 UTC, aberba wrote: Some suggest working with the lowest currency denomination to avoid decimal precision handling and only convert to the highest denominations (decimal) when displaying. I've also seen some use decimal value handling libraries. I'm

Decimal handling for currency (precision)

2017-11-23 Thread aberba via Digitalmars-d-learn
Some suggest working with the lowest currency denomination to avoid decimal precision handling and only convert to the highest denominations (decimal) when displaying. I've also seen some use decimal value handling libraries. I'm thinking lowest denominations will result in extremely large

Re: reduce condition nesting

2017-11-23 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe wrote: On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: for instance in kotlin it can be replace with this: when { c1 -> foo(), c2 -> bar(), c3 -> ... else -> someDefault() } The `switch` statement

Re: Best way to call external function from another process memory?

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2017 at 11:35:18 UTC, Skuzzi wrote: typedef void (__stdcall* _function) (const char *text); I want to do this in D. I understand that D uses "extern (C)" and does away with specifying calling conventions. However, how does D know the calling convention required? What

Re: reduce condition nesting

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: for instance in kotlin it can be replace with this: when { c1 -> foo(), c2 -> bar(), c3 -> ... else -> someDefault() } The `switch` statement covers some of these cases too.

deep copy thread local to shared or how to send() struct with indirections

2017-11-23 Thread crimaniak via Digitalmars-d-learn
Hi! I need to send Publish struct from https://github.com/tchaloupka/vibe-mqtt to another vibe.d task. And there is the problem. First of all, I can't make it immutable because send() wants to mutate it. I can't send local copy because of "Aliases to mutable thread-local data not allowed.".

Re: Mirroring a drawable buf in DLangUI?

2017-11-23 Thread Vadim Lopatin via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 13:45:31 UTC, Dukc wrote: I am using the DrawRescaled method of DrawBuf[1] of DLangUI To draw a PNG image to a CanvasWidget[2] subclass. It has a minor issue of the box bounds showing in area that shoud be transparent but otherwise works well. My question is,

Re: Best way to call external function from another process memory?

2017-11-23 Thread rikki cattermole via Digitalmars-d-learn
On 23/11/2017 11:35 AM, Skuzzi wrote: Hi, I am new to D and I want to use it to create some tools that call certain functions from the process of a game, using an injected DLL written in D. I have reverse engineered the addresses and arguments of the function. Typically this kind of stuff is

Best way to call external function from another process memory?

2017-11-23 Thread Skuzzi via Digitalmars-d-learn
Hi, I am new to D and I want to use it to create some tools that call certain functions from the process of a game, using an injected DLL written in D. I have reverse engineered the addresses and arguments of the function. Typically this kind of stuff is done with C++ and almost all the

Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote: I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated which is a great idea for safe inter-thread communication. Are there any more usage examples for vibe's worker tasks that show how to send instances of

Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote: I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated Further, what does "weakly isolated" mean here http://vibed.org/api/vibe.core.core/runWorkerTask ?

Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn
I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated which is a great idea for safe inter-thread communication. Are there any more usage examples for vibe's worker tasks that show how to send instances of `Isolated` to an existing such worker task via some low-latency

Re: Error: 'this' is only defined in non-static member functions

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-23 01:35, Jonathan M Davis wrote: It would make sense with something like the nodes of a linked list if they needed access to the container for some reason. Pretty much any case where a an instance of a nested class is going to be associated with a specific instance of its parent

Re: reduce condition nesting

2017-11-23 Thread Andrey via Digitalmars-d-learn
On Thursday, 23 November 2017 at 08:27:54 UTC, Andrea Fontana wrote: On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: Hello, is there way to reduce this condition: if (c1) { foo(); } else { if (c2) { bar(); } else { if (c3) { ... } }

Re: glfwSetDropCallback undefined symbol

2017-11-23 Thread drug via Digitalmars-d-learn
23.11.2017 09:33, Tim Hsu пишет: DCD and DMD says that the symbol is undefined! However, I look into derelichtGLFW3. It has this symbol defined! It looks like a bug for me! DerelictGLFW3 has this symbol, but it does not define it, it should be defined in shared/dynamic library you use. I

Re: reduce condition nesting

2017-11-23 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: Hello, is there way to reduce this condition: if (c1) { foo(); } else { if (c2) { bar(); } else { if (c3) { ... } } } for instance in kotlin it can be replace with this: when { c1