Re: Unnable to join Discord

2021-08-26 Thread nayy via Digitalmars-d-learn
Maybe it doesn't like a VPN usage? I will try without it

Re: Unnable to join Discord

2021-08-26 Thread nayy via Digitalmars-d-learn
On Thursday, 12 August 2021 at 18:24:44 UTC, Tejas wrote: On Thursday, 12 August 2021 at 18:11:20 UTC, nayy wrote: Hi I cannot seems to be able to join the discord server It gives me the following error: "unable to accept invit" Is the invitation link expired? https://dlang.org/community.htm

Re: foreach() behavior on ranges

2021-08-26 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 19:51:36 UTC, H. S. Teoh wrote: What I understand from what Andrei has said in the past, is that a range is merely a "view" into some underlying storage; it is not responsible for the contents of that storage. My interpretation of this is that .save will only sa

Re: foreach() behavior on ranges

2021-08-26 Thread frame via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 11:02:23 UTC, Steven Schveighoffer wrote: On 8/25/21 4:31 AM, frame wrote: On Tuesday, 24 August 2021 at 21:15:02 UTC, Steven Schveighoffer wrote: I'm surprised you bring PHP as an example, as it appears their foreach interface works EXACTLY as D does: Yeah, bu

Scope of Mixins

2021-08-26 Thread DLearner via Digitalmars-d-learn
Please confirm that mixins of format: ``` string mxn1(string VarName) { ... } ``` Invoked like: ``` mixin(mxn1("Var1")); ``` Have a wider scope than mixins like: ``` string mxn2(string VarName)() { ... } ``` Invoked like: ``` mixin(mxn2!"Var2"); ``` I tried direct replacement of former by

Re: Scope of Mixins

2021-08-26 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote: Please confirm that mixins of format: ``` string mxn1(string VarName) { ... } ``` Invoked like: ``` mixin(mxn1("Var1")); ``` Have a wider scope than mixins like: ``` string mxn2(string VarName)() { ... } ``` Invoked like: ``` mi

Re: Scope of Mixins

2021-08-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote: Please confirm that mixins of format: You really shouldn't use string mixins like this at all. If you want to work with a variable, pass the variable itself as an argument to the function and use it with regular code instead of pas

Re: Scope of Mixins

2021-08-26 Thread DLearner via Digitalmars-d-learn
On Thursday, 26 August 2021 at 16:28:22 UTC, Adam D Ruppe wrote: On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote: Please confirm that mixins of format: You really shouldn't use string mixins like this at all. If you want to work with a variable, pass the variable itself as an arg

Re: Scope of Mixins

2021-08-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 26 August 2021 at 17:01:06 UTC, DLearner wrote: The object was to take a variable, and do alternative things with it depending on (say) whether it was an 'int' or an 'int*'. That's *very* easy to do with the alias. You can just check `typeof(v)` in there.

Re: Scope of Mixins

2021-08-26 Thread Ali Çehreli via Digitalmars-d-learn
On 8/26/21 10:06 AM, Adam D Ruppe wrote: On Thursday, 26 August 2021 at 17:01:06 UTC, DLearner wrote: The object was to take a variable, and do alternative things with it depending on (say) whether it was an 'int' or an 'int*'. That's *very* easy to do with the alias. You can just check `typeo

Re: Scope of Mixins

2021-08-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 26 August 2021 at 17:39:16 UTC, Ali Çehreli wrote: String mixins are appealing because they can inject code like C macros do. It's not trivially possible to do the same with template mixins. Template mixins are great, but obviously totally inappropriate here. I'm just talking abo

Re: Scope of Mixins

2021-08-26 Thread Ali Çehreli via Digitalmars-d-learn
On 8/26/21 10:45 AM, Adam D Ruppe wrote: On Thursday, 26 August 2021 at 17:39:16 UTC, Ali Çehreli wrote: String mixins are appealing because they can inject code like C macros do. It's not trivially possible to do the same with template mixins. Template mixins are great, but obviously totally

Re: Scope of Mixins

2021-08-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 26 August 2021 at 18:07:48 UTC, Ali Çehreli wrote: In some cases it's more useful to have a 'static if' inside a single function template instead of two separate function templates. In most cases that's better. A template constraint is really a way to say "this template cannot ac

Re: Scope of Mixins

2021-08-26 Thread DLearner via Digitalmars-d-learn
On Thursday, 26 August 2021 at 16:28:22 UTC, Adam D Ruppe wrote: On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote: Please confirm that mixins of format: You really shouldn't use string mixins like this at all. If you want to work with a variable, pass the variable itself as an arg

Re: Scope of Mixins

2021-08-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 26 August 2021 at 19:31:54 UTC, DLearner wrote: if (typeof(v).stringof == "int" ) { Tip: you can instead of string of do if (is(typeof(v) == int)) That is operator lets you compare types directly. (stringof is something you will almost never use as you learn more of the lan

A little help with Ranges

2021-08-26 Thread Merlin Diavova via Digitalmars-d-learn
Hi all, I'm Merlin, I'm just starting out in D and super excited. My questions are:- 1. In a range pipeline how does one handle the event of a filter range returning empty? 2. How does one unwrap a single result from a range operation? Look forward to your assistance! Merlin

Re: A little help with Ranges

2021-08-26 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 27 August 2021 at 01:51:42 UTC, Merlin Diavova wrote: Hi all, I'm Merlin, I'm just starting out in D and super excited. My questions are:- 1. In a range pipeline how does one handle the event of a filter range returning empty? 2. How does one unwrap a single result from a range o

Re: A little help with Ranges

2021-08-26 Thread Merlin Diavova via Digitalmars-d-learn
On Friday, 27 August 2021 at 02:10:48 UTC, Stefan Koch wrote: On Friday, 27 August 2021 at 01:51:42 UTC, Merlin Diavova wrote: Hi all, I'm Merlin, I'm just starting out in D and super excited. My questions are:- 1. In a range pipeline how does one handle the event of a filter range returning

Re: A little help with Ranges

2021-08-26 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 27 August 2021 at 02:17:21 UTC, Merlin Diavova wrote: On Friday, 27 August 2021 at 02:10:48 UTC, Stefan Koch wrote: On Friday, 27 August 2021 at 01:51:42 UTC, Merlin Diavova wrote: Hi all, I'm Merlin, I'm just starting out in D and super excited. My questions are:- 1. In a range p

Re: A little help with Ranges

2021-08-26 Thread Ali Çehreli via Digitalmars-d-learn
On 8/26/21 7:17 PM, Merlin Diavova wrote: What I meant about the handling an empty filter is, what if I want to take an alternative route if the filter returns empty? Then the operations downstream will not produce any results. For example, the array will be empty below: import std.stdio; i

Re: A little help with Ranges

2021-08-26 Thread Merlin Diavova via Digitalmars-d-learn
On Friday, 27 August 2021 at 04:01:19 UTC, Ali Çehreli wrote: On 8/26/21 7:17 PM, Merlin Diavova wrote: [...] Then the operations downstream will not produce any results. For example, the array will be empty below: import std.stdio; import std.range; import std.algorithm; import std.string

A way to mixin during runtime?

2021-08-26 Thread Kirill via Digitalmars-d-learn
Is there a way to do mixin or similar during runtime? I'm trying to read a csv file and extract data types. Any ideas on how this should be approached in D are greatly appreciated.