Re: format with floating points GC allocating in DMD 2.090

2020-02-07 Thread Rainer Schuetze via Digitalmars-d-learn
On 31/01/2020 09:45, bauss wrote: > On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote: >> char[4096] buf; >> writeln(GC.stats.usedSize); >> foreach (i; 0 .. 10) { >>     sformat(buf, "%f", 1.234f); >>     writeln(GC.stats.usedSize); >> } >> >> Output with DMD32 D Compi

Re: How to use sets in D?

2020-02-07 Thread mark via Digitalmars-d-learn
On Friday, 7 February 2020 at 22:03:00 UTC, H. S. Teoh wrote: On Fri, Feb 07, 2020 at 07:37:08PM +, mark via Digitalmars-d-learn wrote: [snip] bool[E] works just fine. [snip] Or you can wrap void[0][E] in a nice user-defined type that gives nice set-like syntax. But IMO, this is all over

Re: Flatten a range of static arrays

2020-02-07 Thread ag0aep6g via Digitalmars-d-learn
On 08.02.20 02:38, ag0aep6g wrote: Simplified, we're looking at this: struct Joiner {     int[3] _items;     int[] _current; } void main() @safe {     Joiner j;     j._current = j._items[]; } I.e., a self-referential struct. Or most fundamentally: struct Joiner {     Joiner

Re: total newbie + IDE

2020-02-07 Thread Borax Man via Digitalmars-d-learn
On Friday, 7 February 2020 at 17:02:18 UTC, solnce wrote: Hi guys, I am total newbie and trying to learn a little bit of programming for personal purposes (web scrapping, small databases for personal use etc.). I've been trying to install any of IDE available, but had no success. I use Manj

Re: Flatten a range of static arrays

2020-02-07 Thread ag0aep6g via Digitalmars-d-learn
On 08.02.20 01:17, Steven Schveighoffer wrote: The original code is not invalid though. f is not valid, and that is a bug, but the original code posted by nullptr should be fine by memory safety standards. Maybe. But then it should also work with `int[3] front;`. If there is no possible way t

Re: Flatten a range of static arrays

2020-02-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/7/20 6:30 PM, ag0aep6g wrote: On 08.02.20 00:10, nullptr wrote: ``` import std; struct SomeRange { int[3] val; enum empty = false; auto popFront() @safe {} ref auto front() @safe { return val; } } void main() @safe { SomeRange().take(10).map!

Re: Flatten a range of static arrays

2020-02-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/7/20 6:10 PM, nullptr wrote: ``` import std; struct SomeRange {     int[3] val;     enum empty = false;     auto popFront() @safe {}     ref auto front() @safe     {     return val;     } } void main() @safe {     SomeRange().take(10).map!((return ref x) => x[]).joiner.writ

Re: Flatten a range of static arrays

2020-02-07 Thread ag0aep6g via Digitalmars-d-learn
On 08.02.20 00:10, nullptr wrote: ``` import std; struct SomeRange {     int[3] val;     enum empty = false;     auto popFront() @safe {}     ref auto front() @safe     {     return val;     } } void main() @safe {     SomeRange().take(10).map!((return ref x) => x[]).joiner.write

Re: Flatten a range of static arrays

2020-02-07 Thread nullptr via Digitalmars-d-learn
On Friday, 7 February 2020 at 22:55:29 UTC, Dennis wrote: Oops, minimized a bit too much. Corrected test case: ``` import std; struct S { @safe: int[3] front = [10, 20, 30]; bool empty = false; void popFront() {empty = true;} } void main() @safe { S.init.map!((return ref x)

Re: Flatten a range of static arrays

2020-02-07 Thread Dennis via Digitalmars-d-learn
On Friday, 7 February 2020 at 21:40:36 UTC, Steven Schveighoffer wrote: S.popFront is not @safe, and S is not a template. So no inferrence. Oops, minimized a bit too much. Corrected test case: ``` import std; struct S { @safe: int[3] front = [10, 20, 30]; bool empty = false; voi

Re: How to use sets in D?

2020-02-07 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Feb 07, 2020 at 07:37:08PM +, mark via Digitalmars-d-learn wrote: > I am porting code from other languages to D as part of learning D, and > I find I've used sets quite a lot. AFAIK D doesn't have a built-in set > type or one in the std. lib. > > However, I've been perfectly successful

Re: Flatten a range of static arrays

2020-02-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/7/20 4:17 PM, Dennis wrote: On Friday, 7 February 2020 at 20:55:14 UTC, nullptr wrote: Depending on how your range is structured, it might be possible to just mark front as returning by ref to make this work. That's a good one. I can't make front() return by ref, but I can make front a m

Re: Flatten a range of static arrays

2020-02-07 Thread Dennis via Digitalmars-d-learn
On Friday, 7 February 2020 at 20:55:14 UTC, nullptr wrote: Depending on how your range is structured, it might be possible to just mark front as returning by ref to make this work. That's a good one. I can't make front() return by ref, but I can make front a member variable of the range struct

Re: Flatten a range of static arrays

2020-02-07 Thread Dennis via Digitalmars-d-learn
On Friday, 7 February 2020 at 20:31:47 UTC, Steven Schveighoffer wrote: The only solution I can provide is to wrap the static array into a range (maybe something like this exists in Phobos?): Thanks. I was hoping something like that existed in Phobos, but I can't find anything.

Re: Flatten a range of static arrays

2020-02-07 Thread nullptr via Digitalmars-d-learn
On Friday, 7 February 2020 at 20:13:57 UTC, Dennis wrote: If I have an input range with element type `int[3]`, how do I easily turn it into a range of `int` so I can map it? If it were an int[3][] I could simply cast it to an int[] before mapping, but I don't want to eagerly turn it into an arr

Re: Flatten a range of static arrays

2020-02-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/7/20 3:13 PM, Dennis wrote: If I have an input range with element type `int[3]`, how do I easily turn it into a range of `int` so I can map it? If it were an int[3][] I could simply cast it to an int[] before mapping, but I don't want to eagerly turn it into an array. I thought of doing th

Flatten a range of static arrays

2020-02-07 Thread Dennis via Digitalmars-d-learn
If I have an input range with element type `int[3]`, how do I easily turn it into a range of `int` so I can map it? If it were an int[3][] I could simply cast it to an int[] before mapping, but I don't want to eagerly turn it into an array. I thought of doing this: ``` range.map!(x => x[]).joine

Re: How to use sets in D?

2020-02-07 Thread Jan Hönig via Digitalmars-d-learn
On Friday, 7 February 2020 at 19:37:08 UTC, mark wrote: I am porting code from other languages to D as part of learning D, and I find I've used sets quite a lot. AFAIK D doesn't have a built-in set type or one in the std. lib. However, I've been perfectly successfully using int[E] where E is

How to use sets in D?

2020-02-07 Thread mark via Digitalmars-d-learn
I am porting code from other languages to D as part of learning D, and I find I've used sets quite a lot. AFAIK D doesn't have a built-in set type or one in the std. lib. However, I've been perfectly successfully using int[E] where E is my ElementType, and adding with set[element] = 0. I mostl

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Thanks for the excellent replies.

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread Basile B. via Digitalmars-d-learn
On Friday, 7 February 2020 at 08:52:44 UTC, mark wrote: Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D? Yes assuming that the expression is bool evaluable. This includes - pointers: `if (auto p = giveMeSomePtr()

Re: total newbie + IDE

2020-02-07 Thread Basile B. via Digitalmars-d-learn
On Friday, 7 February 2020 at 18:10:07 UTC, bachmeier wrote: On Friday, 7 February 2020 at 17:02:18 UTC, solnce wrote: Hi guys, I am total newbie and trying to learn a little bit of programming for personal purposes (web scrapping, small databases for personal use etc.). I've been trying to i

Re: total newbie + IDE

2020-02-07 Thread bachmeier via Digitalmars-d-learn
On Friday, 7 February 2020 at 17:02:18 UTC, solnce wrote: Hi guys, I am total newbie and trying to learn a little bit of programming for personal purposes (web scrapping, small databases for personal use etc.). I've been trying to install any of IDE available, but had no success. I use Manj

Re: total newbie + IDE

2020-02-07 Thread JN via Digitalmars-d-learn
On Friday, 7 February 2020 at 17:02:18 UTC, solnce wrote: Hi guys, I am total newbie and trying to learn a little bit of programming for personal purposes (web scrapping, small databases for personal use etc.). I've been trying to install any of IDE available, but had no success. [...] Tr

total newbie + IDE

2020-02-07 Thread solnce via Digitalmars-d-learn
Hi guys, I am total newbie and trying to learn a little bit of programming for personal purposes (web scrapping, small databases for personal use etc.). I've been trying to install any of IDE available, but had no success. I use Manjaro, so for the most task I use its AUR, where: Dexed poin

Re: Can't compile dlangui

2020-02-07 Thread bachmeier via Digitalmars-d-learn
On Friday, 7 February 2020 at 14:25:05 UTC, Jan Hönig wrote: I am afraid that dlangui and dlangide is currently not maintained, since i can reproduce the error as well. If you're sure that's the case, then it should be pushed to the inactive section on this page: https://wiki.dlang.org/IDEs

Re: D create many thread

2020-02-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/7/20 2:34 AM, bauss wrote: On Thursday, 6 February 2020 at 22:00:26 UTC, tchaloupka wrote: On Wednesday, 5 February 2020 at 13:05:59 UTC, Eko Wahyudin wrote: Hi all, I'm create a small (hallo world) application, with DMD. But my program create 7 annoying threads when create an empty class

Re: Can't compile dlangui

2020-02-07 Thread Jan Hönig via Digitalmars-d-learn
On Friday, 7 February 2020 at 12:04:10 UTC, A.Perea wrote: Hi, I'm trying to compile dlangide, and it fails when compiling the dependency dlangui. Trying to compile dlangui independently gives the same error message (see below for full stack trace) As phobos nor dlangui can be broken, it sho

Can't compile dlangui

2020-02-07 Thread A.Perea via Digitalmars-d-learn
Hi, I'm trying to compile dlangide, and it fails when compiling the dependency dlangui. Trying to compile dlangui independently gives the same error message (see below for full stack trace) As phobos nor dlangui can be broken, it should be something related to wrong installation on my side?,

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 7 February 2020 at 08:52:44 UTC, mark wrote: Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D? Yes and no. It only works for bools or things that convert to bool. You might have seen: string[string] d

Re: How make Executable Dlang EXE ask for "Run as Administrator"?

2020-02-07 Thread Marcone via Digitalmars-d-learn
Solved adding this code in resource.rc, converted to resource.res and linked to .d source. This code add the file "manifest.manifest" to resource. 1 24 "manifest.manifest"

Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D?