splitter and matcher combined regex

2019-06-16 Thread Amex via Digitalmars-d-learn
Having to split and match seems slow(50%). Surely the regex splitter and matcher can be combined? Sometimes we just need to extract out and remove information simultaneously. I propose a new function called extractor that returns the matchAll and splitter's results but is optimized.

Scope exit bug?

2019-06-13 Thread Amex via Digitalmars-d-learn
void foo() { void bar() { foo; } switch case: scope(exit) { do } break bar; } fails to execute do void foo() { void bar() { foo; } switch case: bar; do return; bar; } does work... yet there is no difference except the scope exit. In my code it is if do

arsd dom

2019-06-12 Thread Amex via Digitalmars-d-learn
When parsing an xml file I get #text for tagName on basically every other element. I'm trying to recurse through all the elements using void recurse(T)(T parent, int depth = 0) { foreach(c; parent.children) { recurse(c,

Re: if (X !is null && X.Y !is null) access crash

2019-06-10 Thread Amex via Digitalmars-d-learn
On Monday, 10 June 2019 at 19:48:18 UTC, Steven Schveighoffer wrote: On 6/9/19 1:25 AM, Amex wrote: On Saturday, 8 June 2019 at 20:44:13 UTC, Steven Schveighoffer wrote: Try GC.addRef on the X reference, and see if it helps. This is during shutdown so I imagine simply turning off the GC

Re: if (X !is null && X.Y !is null) access crash

2019-06-08 Thread Amex via Digitalmars-d-learn
On Saturday, 8 June 2019 at 20:44:13 UTC, Steven Schveighoffer wrote: On 6/8/19 2:28 AM, Amex wrote: On Friday, 7 June 2019 at 16:09:47 UTC, Adam D. Ruppe wrote: It happens when I close down my app. is this inside a destructor? No, it's in an external thread(it is in a callback). All I can

Can D optimize?

2019-06-08 Thread Amex via Digitalmars-d-learn
Can dmd or ldc optimize the following cases: foo(int x) { if (x > 10 && x < 100) bar1; else bar2; } ... for(int i = 23; i < 55; i++) foo(i); // equivalent to calling bar1(i) clearly i is within the range of the if in foo and so the checks are unnecessary. I realize that this is

Re: if (X !is null && X.Y !is null) access crash

2019-06-08 Thread Amex via Digitalmars-d-learn
On Friday, 7 June 2019 at 16:09:47 UTC, Adam D. Ruppe wrote: It happens when I close down my app. is this inside a destructor? No, it's in an external thread(it is in a callback). All I can think of is that something is happening in between the two checks since there is no way it could

Re: if (X !is null && X.Y !is null) access crash

2019-06-07 Thread Amex via Digitalmars-d-learn
On Friday, 7 June 2019 at 14:07:34 UTC, KnightMare wrote: On Friday, 7 June 2019 at 09:26:52 UTC, Amex wrote: if (X !is null && X.Y !is null) access crash is crashing. imo this code is valid. u can write shorter if (X && X.Y) probably crashed in some another place (X is not objRef but

Re: FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-07 Thread Amex via Digitalmars-d-learn
On Thursday, 6 June 2019 at 20:52:42 UTC, Steven Schveighoffer wrote: On 6/6/19 4:49 PM, Steven Schveighoffer wrote: Oh wait! It's not empty, it has an empty string as a single member! That's definitely a bug. OK, not a bug, but not what I would have expected. From docs: "If T isn't a

if (X !is null && X.Y !is null) access crash

2019-06-07 Thread Amex via Digitalmars-d-learn
I don't understand why if (X !is null && X.Y !is null) access crash is crashing. It is true that it is being used in a thread. It happens when I close down my app. The whole point of the check is to make sure X is not null but it seems to be failing. The debugger is showing X is not null

FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Amex via Digitalmars-d-learn
FieldNameTuple!T std.traits.Fields!T are non-empty when T is an interface! An interface cannot contain fields and yet these return non-zero and screws up my code. While I can filter for interfaces it makes me wonder what else may slip through? Is it a bug or what is going on?

typeid, typeinfo, classinfo not returning most derived

2019-06-06 Thread Amex via Digitalmars-d-learn
- x 0x004b71e0 {Interface for main.I} {m_init={length=0 ptr=0x}, name="main.I", vtbl={length=0 ptr=0x}, ...} object.TypeInfo_Class {TypeInfo_Class} [TypeInfo_Class]D0006: Error: Type resolve failed m_init {length=0 ptr=0x}

-v lots of junk

2019-06-05 Thread Amex via Digitalmars-d-learn
Using -v I get a whole list(100's) of stuff that is irrelevant: ... import core.sys.windows.w32api (C:\dmd2\windows\bin\..\..\src\druntime\import\core\sys\windows\w32api.d) import core.sys.windows.basetyps (C:\dmd2\windows\bin\..\..\src\druntime\import\core\sys\windows\basetyps.d) import

Re: Very simple null reference escape

2019-06-02 Thread Amex via Digitalmars-d-learn
On Sunday, 2 June 2019 at 14:37:48 UTC, Paul Backus wrote: On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; The "optional" package on dub [1] has a .dispatch

Error: module `M.Q` from file M\Q.d conflicts with another module Q from file M\Q.d

2019-06-02 Thread Amex via Digitalmars-d-learn
main.d(217): Error: module `M.Q` from file M\Q.d conflicts with another module Q from file M\Q.d the line is simply import Q : foo; the problem is that it should have been import M.Q : foo; There is no module Q. The error message is in error! There is no other module. the module is named

import and call

2019-06-02 Thread Amex via Digitalmars-d-learn
Tired of having to import a single function to call it. Since mod.foo(x); doesn't work since mod is not defined. we have to do import mod : foo; foo(x); Why not mod:foo(x)? or mod#foo(x) or mod@foo(x) or whatever Reduces 50% of the lines and reduces the import symbol. I realize

Very simple null reference escape

2019-06-02 Thread Amex via Digitalmars-d-learn
A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B;

Re: emulate with

2019-05-31 Thread Amex via Digitalmars-d-learn
On Friday, 31 May 2019 at 08:35:23 UTC, Simen Kjærås wrote: On Friday, 31 May 2019 at 07:17:22 UTC, Amex wrote: What I'm talking about is that if A would be dispatched to, say, W!X where W handles the special dispatching by returning X_A rather than X.A. I don't know if D can do this kinda

emulate with

2019-05-31 Thread Amex via Digitalmars-d-learn
with lets one remove a direct reference... The problem is the things I want to access are not part of a single object but have a common naming structure: X_A X_B X_C_Q (rather than X.A, X.B, X.C.Q) it would be very helpful(since X is long) to be able to do something like with(X) { A;

Adding a payload to a type

2019-05-27 Thread Amex via Digitalmars-d-learn
I have some types I've declared and I'd like to magically extend them and add data. The problem is I inheriting from them them is bad news. Suppose, for example, I have an image type that is used in an application. For a small part of the application it needs to associate with each image

Re: GtkD slows down visual D keyboard

2019-04-26 Thread Amex via Digitalmars-d-learn
On Friday, 26 April 2019 at 14:50:17 UTC, Mike Wey wrote: On 26-04-2019 10:31, Amex wrote: When debugging under visual D, the keyboard response is slowed down to the extreme. This is a Gtk issue I believe. It only has to do with the keyboard. For example, if I hit F10 to step, it takes the

GtkD slows down visual D keyboard

2019-04-26 Thread Amex via Digitalmars-d-learn
When debugging under visual D, the keyboard response is slowed down to the extreme. This is a Gtk issue I believe. It only has to do with the keyboard. For example, if I hit F10 to step, it takes the ide about 10 seconds to "respond" and move to the next line... yet the mouse can access