Re: question as to when a new command gets executed

2020-11-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-11 06:29, WhatMeWorry wrote: Which begs the question, how would the statement, m_State = new BreakState() ever get executed? class DebuggerSession {     private BreakState m_State = new BreakState();     private UnrealCallback m_UnrealCallback;     this( )     {     }     //

question as to when a new command gets executed

2020-11-10 Thread WhatMeWorry via Digitalmars-d-learn
I've been studying an 8 year old D project in Github and this code fragment has left me befuddled. I'm confused as to when and how the new BreakState() statement gets executed. Wouldn't the class DebuggerSession need to be instantiated first and then the this() constructor be called? Which

Re: Unclear error message

2020-11-10 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 11 November 2020 at 02:05:33 UTC, H. S. Teoh wrote: Definitely. Bad/confusing error messages should always be improved. Please file a bug at: http://issues.dlang.org/ T https://issues.dlang.org/show_bug.cgi?id=21377 I wonder if this is the same as:

Re: Unclear error message

2020-11-10 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 11, 2020 at 01:05:21AM +, SealabJaster via Digitalmars-d-learn wrote: > Please see the code at https://run.dlang.io/is/Yjidek [Quoting code in full here for future reference] > struct PreValidate > { > alias FuncT = bool delegate(string arg); > > FuncT func; > >

Re: Unclear error message

2020-11-10 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 11 November 2020 at 01:05:21 UTC, SealabJaster wrote: Please see the code at https://run.dlang.io/is/Yjidek As I understand the error is caused by trying to provide a delegate when there's no context to provide. Not complaining about that. However what I am complaining about

Unclear error message

2020-11-10 Thread SealabJaster via Digitalmars-d-learn
Please see the code at https://run.dlang.io/is/Yjidek As I understand the error is caused by trying to provide a delegate when there's no context to provide. Not complaining about that. However what I am complaining about is about the error message: `onlineapp.d(31): Error: delegate

Re: Unicode Regular Expressions

2020-11-10 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 9 November 2020 at 17:06:50 UTC, H. S. Teoh wrote: I'm pretty sure std.regex already supports Unicode regexes. Yep [1]. Thanks [1] https://dlang.org/phobos/std_regex.html#Syntax%20and%20general%20information

Re: Generic comparison

2020-11-10 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 20:32:40 UTC, Paul Backus wrote: The compiler infers pure, @nogc, nothrow etc. for template functions automatically. It's actually better if you don't add them by hand. Ok, thanks :-).

Re: Generic comparison

2020-11-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 20:32:40 UTC, Paul Backus wrote: alias isOrderingComparableWith(T, U) = __traits(compiles, (T t, U u) => t < u); My bad, should be `enum`, not `alias`.

Re: Generic comparison

2020-11-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 17:19:09 UTC, Ola Fosheim Grøstad wrote: Interesting, so "auto ref T" is the go-to type specifier for generic code then? I guess I also should conditionally add things like pure, nogc, nothrow... I assume I would have to test the comparison operator. I

Re: How to get address of a nested function?

2020-11-10 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Nov 10, 2020 at 11:55 AM Max Samukha via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > We can get the compile time equivalent of a member function's > address by applying '&' to the function in a static context: > > struct S { > void foo() {} > } > > enum pfoo =

Re: How to get address of a nested function?

2020-11-10 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Nov 10, 2020 at 8:50 PM Max Samukha via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 10 November 2020 at 14:36:04 UTC, Steven > Schveighoffer wrote: > > >> > >> Is there a way to get a pointer to a non-static nested > >> function? > > > > I don't think you

Re: How to get address of a nested function?

2020-11-10 Thread Max Samukha via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 14:36:04 UTC, Steven Schveighoffer wrote: Is there a way to get a pointer to a non-static nested function? I don't think you can do it at compile time. You can at runtime by accessing the funcptr of the delegate. -Steve Thanks for the reply. I will post

Re: Generic comparison

2020-11-10 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 17:09:00 UTC, Paul Backus wrote: bool between(Value, Bound)(auto ref Value value, auto ref Bound low, auto ref Bound high) { return (low < value) && (value < high); } You need `auto ref` because either Bound or Value may have copying disabled. Because the

Re: Generic comparison

2020-11-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 16:55:11 UTC, Ola Fosheim Grøstad wrote: I want to implement a generic function for "a < f(x) < b" that will give the same result as "(a < f(x)) && (f(x) < b)" for any conceivable mix of types. Except if that "f(x)" should only be evaluated once. Is it

Generic comparison

2020-11-10 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
I want to implement a generic function for "a < f(x) < b" that will give the same result as "(a < f(x)) && (f(x) < b)" for any conceivable mix of types. Except if that "f(x)" should only be evaluated once. Is it sufficient to use "scope ref" in parameters? I don't want to assume _anything_

Re: How to get address of a nested function?

2020-11-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/10/20 5:51 AM, Max Samukha wrote: We can get the compile time equivalent of a member function's address by applying '&' to the function in a static context: struct S {     void foo() {} } enum pfoo = // ok void main() {     // now we can use the pointer to create, for example, a

Re: canFind all elements in a array.

2020-11-10 Thread Vino via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 09:47:06 UTC, sarn wrote: On Tuesday, 10 November 2020 at 08:19:15 UTC, Vino wrote: [...] This is iterating over all the elements in data2 and outputting some of them, so the output will never be longer than data2. [...] Hi Sarn, Thank you very much

Re: Disallow implicit "conversion" from alias-types

2020-11-10 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 11:49:19 UTC, Jerry wrote: On Tuesday, 10 November 2020 at 11:38:30 UTC, Vladimirs Nordholm wrote: Hello. I am unsure if I am going about this the right way, and if my question even makes sense. In essence what I want is to have two "types" represented by a

Re: Disallow implicit "conversion" from alias-types

2020-11-10 Thread Jerry via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 11:38:30 UTC, Vladimirs Nordholm wrote: Hello. I am unsure if I am going about this the right way, and if my question even makes sense. In essence what I want is to have two "types" represented by a size_t. Here is an example of what I want think I want (but

Disallow implicit "conversion" from alias-types

2020-11-10 Thread Vladimirs Nordholm via Digitalmars-d-learn
Hello. I am unsure if I am going about this the right way, and if my question even makes sense. In essence what I want is to have two "types" represented by a size_t. Here is an example of what I want think I want (but might be completely off) alias Foo = size_t; alias Bar =

How to get address of a nested function?

2020-11-10 Thread Max Samukha via Digitalmars-d-learn
We can get the compile time equivalent of a member function's address by applying '&' to the function in a static context: struct S { void foo() {} } enum pfoo = // ok void main() { // now we can use the pointer to create, for example, a delegate S s; void delegate() dg;

Re: canFind all elements in a array.

2020-11-10 Thread sarn via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 08:19:15 UTC, Vino wrote: foreach(i; data2[]) { if(data1[].canFind(i[0])) { writeln(i[1]); } } This is iterating over all the elements in data2 and outputting some of them, so the output will never be longer than data2. It looks like you want to

canFind all elements in a array.

2020-11-10 Thread Vino via Digitalmars-d-learn
Hi All, Request your help, the below code output's as below hence request your help on hot to get the output as below(Required Output). Output DEV Cluster QAS Cluster Required Output DEV Cluster DEV Cluster DEV Cluster QAS Cluster Code import std.container.array; import std.stdio: