Re: Some code that compiles but shouldn't

2019-12-30 Thread Heromyth via Digitalmars-d-learn
On Monday, 30 December 2019 at 18:18:49 UTC, uranuz wrote: I have created library/ framework to handle JSON-RPC requests using D methods. I use some *template magic* to translate JSON-RPC parameters and return values from/ and to JSON. And I have encountered funny bug that at first was hard to

Re: Finding position of a value in an array

2019-12-30 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 31 December 2019 at 04:38:53 UTC, Daren Scot Wilson wrote: I'm needing to see more examples. It might have something to do with the array I'm working with being inside a foreach loop. My code looks like this, with the problematic line duplicated to show some of the variations I

How to use ResizerWidget in Dlangui app..?

2019-12-30 Thread ShadoLight via Digitalmars-d-learn
Hi, I suspect I'm missing something obvious, but ResizerWidget is not working for me on Windows - it shows the 'dragging'-cursor when hovering the mouse on the ResizerWidget, but dragging with the left mouse button does nothing. Reduced very simple example: ///app.d import dlangui; import

Re: Finding position of a value in an array

2019-12-30 Thread Daren Scot Wilson via Digitalmars-d-learn
On Monday, 30 December 2019 at 23:15:48 UTC, JN wrote: On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: int i = a.countUntil!(v => v == 55); assert(i == 2); I also had to ask because I couldn't find it. In other languages it's named "index()", "indexOf()" or "find()". D is the

Re: What type does byGrapheme() return?

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 29, 2019 at 01:19:09PM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2019-12-27 19:44:59 +, H. S. Teoh said: [...] > > If you want to add/delete/change graphemes, what you *really* want > > is to use an array of Graphemes: > > > > Grapheme[] editableGraphs; > >

Re: What type does byGrapheme() return?

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 30, 2019 at 03:31:31PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: > On Mon, Dec 30, 2019 at 03:09:58PM -0800, H. S. Teoh via Digitalmars-d-learn > wrote: > [...] > > I suspect the cause is that whatever Grapheme.opSlice returns is > > going out-of-scope when used with .map,

Re: Finding position of a value in an array

2019-12-30 Thread JN via Digitalmars-d-learn
On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: int i = a.countUntil!(v => v == 55); assert(i == 2); I also had to ask because I couldn't find it. In other languages it's named "index()", "indexOf()" or "find()". D is the only language I know which uses the "countUntil" scheme.

Re: What type does byGrapheme() return?

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 30, 2019 at 03:09:58PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > I suspect the cause is that whatever Grapheme.opSlice returns is going > out-of-scope when used with .map, that's why it's malfunctioning. [...] Haha, it's actually right there in the Grapheme docs for

Re: What type does byGrapheme() return?

2019-12-30 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 27 December 2019 at 17:26:58 UTC, Robert M. Münch wrote: ... There are set of range interfaces that can be used to mask range type. Check for https://dlang.org/library/std/range/interfaces/input_range.html for starting point, and for

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Piotr Mitana via Digitalmars-d-learn
On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc wrote: There are lots of editors/IDE's that support D language: https://wiki.dlang.org/Editors What kind of editor/IDE are you using and which one do you like the most? IntelliJ IDEA CE with this extension:

Re: Concatenation/joining strings together in a more readable way

2019-12-30 Thread Marcone via Digitalmars-d-learn
On Monday, 30 December 2019 at 09:41:55 UTC, mipri wrote: On Monday, 30 December 2019 at 06:47:37 UTC, Marcone wrote: Use Python format() style: import std; import std: Format = format; // format() string format(T...)(T text){ string texto = text[0]; foreach(count, i;

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/12/2019 9:19 PM, Piotr Mitana wrote: On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc wrote: There are lots of editors/IDE's that support D language: https://wiki.dlang.org/Editors What kind of editor/IDE are you using and which one do you like the most? IntelliJ IDEA CE with this

Re: How create a function that receive a function and run it in another threading?

2019-12-30 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 27 December 2019 at 07:06:52 UTC, mipri wrote: On Friday, 27 December 2019 at 06:08:16 UTC, Marcone wrote: import std; import core.thread; auto threading(lazy void fun){ return task!fun().executeInNewThread(); } void main(){ threading(writeln("Hello World!")); } I want

Re: Concatenation/joining strings together in a more readable way

2019-12-30 Thread mipri via Digitalmars-d-learn
On Monday, 30 December 2019 at 06:47:37 UTC, Marcone wrote: Use Python format() style: import std; import std: Format = format; // format() string format(T...)(T text){ string texto = text[0]; foreach(count, i; text[1..$]){ texto = texto.replaceFirst("{}",

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread bachmeier via Digitalmars-d-learn
On Monday, 30 December 2019 at 06:43:03 UTC, H. S. Teoh wrote: Generally, I find myself *much* more productive with CLI-based tools; IDEs are generally much heavier in terms of memory and CPU usage, and worst of all, require a GUI, which for me is a deal-breaker because I do a lot of work

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 29 December 2019 at 14:41:46 UTC, Russel Winder wrote: On Sat, 2019-12-28 at 22:01 +, p.shkadzko via Digitalmars-d-learn wrote: […] p.s. I found it quite satisfying that D does not really need an IDE, you will be fine even with nano. The fundamental issue with these all

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Ron Tarrant via Digitalmars-d-learn
On Sunday, 29 December 2019 at 21:25:44 UTC, Adam D. Ruppe wrote: My experience is IDEs are just different, not necessarily better or worse. Just different enough that people used to one find the others difficult to learn. Amen, hear-hear, and all that. I thought it was just me.

Re: Finding position of a value in an array

2019-12-30 Thread Ron Tarrant via Digitalmars-d-learn
On Sunday, 29 December 2019 at 09:44:18 UTC, MoonlightSentinel wrote: int i = a.countUntil(55); I was trying to do this with an array of pointers, but I get an error (which suggests to me that I don't know what data type a pointer is): find_in_array_object.d(25): Error: cannot cast

Re: Finding position of a value in an array

2019-12-30 Thread mipri via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:30:12 UTC, Ron Tarrant wrote: On Sunday, 29 December 2019 at 09:44:18 UTC, MoonlightSentinel wrote: int i = a.countUntil(55); I was trying to do this with an array of pointers, but I get an error (which suggests to me that I don't know what data type a

Re: Concatenation/joining strings together in a more readable way

2019-12-30 Thread mipri via Digitalmars-d-learn
On Monday, 30 December 2019 at 10:23:14 UTC, Marcone wrote: On Monday, 30 December 2019 at 09:41:55 UTC, mipri wrote: This leaks too much. writeln("Helo {} {}".format("xx", "name")); // Helo xx name writeln("Helo {} {}".format("{}", "name")); // Helo name {} This function replace {}

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 30, 2019 at 04:13:03PM +, Patrick Schluter via Digitalmars-d-learn wrote: [...] > Good point. It also trains people to not be able to work without IDE. > I see it at work with some of the Java devs who aren't even able to > invoke javac in a command line and setting javapath

Some code that compiles but shouldn't

2019-12-30 Thread uranuz via Digitalmars-d-learn
I have created library/ framework to handle JSON-RPC requests using D methods. I use some *template magic* to translate JSON-RPC parameters and return values from/ and to JSON. And I have encountered funny bug that at first was hard to find. My programme just segfaulted when call to this

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:59:22 UTC, bachmeier wrote: On Monday, 30 December 2019 at 06:43:03 UTC, H. S. Teoh wrote: [...] Another way in which the IDE is "heavy" is the amount of overhead for beginning/occasional users. I like that I can get someone started using D like this: 1.

Re: Some code that compiles but shouldn't

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 30, 2019 at 06:18:49PM +, uranuz via Digitalmars-d-learn wrote: [...] > void getCompiledTemplate(HTTPContext ctx) > { > import std.exception: enforce; > enforce(ctx, `ctx is null`); > enforce(ctx.request, `ctx.request is null`);

Re: Finding position of a value in an array

2019-12-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:30:12 UTC, Ron Tarrant wrote: I was trying to do this with an array of pointers, but I get an error (which suggests to me that I don't know what data type a pointer is): It's not a ulong? Have I forgotten so much? D disallows implicit conversion from

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 30, 2019 at 02:59:22PM +, bachmeier via Digitalmars-d-learn wrote: [...] > An IDE adds a crapload to the learning curve. It's terrible, because > they need to memorize a bunch of steps when they use a GUI (click here > -> type this thing in this box -> click here -> ...) [...] To

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/30/19 1:43 AM, H. S. Teoh wrote: On Mon, Dec 30, 2019 at 01:26:11AM +, bachmeier via Digitalmars-d-learn wrote: [...] I have trouble seeing how an IDE is going to make anyone a better programmer. [...] Yeah, I call BS on that statement. OTOH, it's certainly a valid point that IDE

Re: Finding position of a value in an array

2019-12-30 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 30 December 2019 at 17:12:26 UTC, MoonlightSentinel wrote: D disallows implicit conversion from integers to pointers and hence they cannot be compared. You would need to explicitly cast your ulong to an appropriate pointer type I'm not trying to convert, just wade through an

Re: Some code that compiles but shouldn't

2019-12-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 30 December 2019 at 18:18:49 UTC, uranuz wrote: So as you see I have added a lot of enforce to test if all variables are not null. But nothing was null and the reason of segfault were unclear. What about moduleName, mod and the return value of mod.toStdJSON()? And whats the

Re: Finding position of a value in an array

2019-12-30 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:39:04 UTC, mipri wrote: You can definitely do it: $ rdmd --eval 'int a, b, c; [, , ].countUntil().writeln' 2 But you need to have an array of pointers. Thanks, mipri. Got it sorted. Here's a working proof... ``` import std.stdio; import std.algorithm;

Re: Some code that compiles but shouldn't

2019-12-30 Thread uranuz via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:09:13 UTC, MoonlightSentinel wrote: On Monday, 30 December 2019 at 18:18:49 UTC, uranuz wrote: So as you see I have added a lot of enforce to test if all variables are not null. But nothing was null and the reason of segfault were unclear. What about

Re: Finding position of a value in an array

2019-12-30 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:46:50 UTC, Ron Tarrant wrote: Thanks, mipri. Got it sorted. Here's a working proof... Forgot to show the output: object: 17B0A831000, ID: 8 object: 17B0A831020, ID: 9 object: 17B0A831060, ID: 10 object: 17B0A831080, ID: 11 object: 17B0A8310A0, ID: 12 object:

Re: Some code that compiles but shouldn't

2019-12-30 Thread uranuz via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:09:13 UTC, MoonlightSentinel wrote: On Monday, 30 December 2019 at 18:18:49 UTC, uranuz wrote: So as you see I have added a lot of enforce to test if all variables are not null. But nothing was null and the reason of segfault were unclear. What about

Re: Finding position of a value in an array

2019-12-30 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:41:55 UTC, mipri wrote: What's your code? 'find_in_array_object.MyObject' doesn't look like a pointer. It's an array of objects... or, what it's trying to be, an array of object pointers.

Re: Finding position of a value in an array

2019-12-30 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:08:27 UTC, Ron Tarrant wrote: I'm not trying to convert, just wade through an array of pointers to find a specific pointer using searchUntil(). ** that should read: countUntil(), not searchUntil() * Turns out I was getting too complicated.

Re: Finding position of a value in an array

2019-12-30 Thread mipri via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:08:27 UTC, Ron Tarrant wrote: On Monday, 30 December 2019 at 17:12:26 UTC, MoonlightSentinel wrote: D disallows implicit conversion from integers to pointers and hence they cannot be compared. You would need to explicitly cast your ulong to an appropriate

Re: Finding position of a value in an array

2019-12-30 Thread mipri via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:46:50 UTC, Ron Tarrant wrote: Thanks, mipri. Got it sorted. Here's a working proof... ``` import std.stdio; import std.algorithm; import std.conv; void main(string[] args) { MyObject[] objectArray; MyObject newObject; MyObject