Re: D's Continous Changing

2021-03-04 Thread Siemargl via Digitalmars-d-learn
On Friday, 5 March 2021 at 03:32:35 UTC, harakim wrote: I want this almost every week at work. When I run into some trivial statement that I need to know for sure how it works, it's rarely worth it to create a whole new file and make a main method and all that. I just edit and run the entire pr

Re: Can't I allocate at descontructor?

2021-03-04 Thread evilrat via Digitalmars-d-learn
On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why? GC prohibits allocation during collection, since this dtor is likely called b

Re: Is there any generic iteration function that stops at first match?

2021-03-04 Thread mipri via Digitalmars-d-learn
On Friday, 5 March 2021 at 05:32:27 UTC, Jack wrote: On Friday, 5 March 2021 at 02:43:36 UTC, H. S. Teoh wrote: On Fri, Mar 05, 2021 at 02:13:39AM +, Jack via Digitalmars-d-learn wrote: something like filter[1] but that stops at first match? are there any native functions for this in D or I

Re: Is there any generic iteration function that stops at first match?

2021-03-04 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 04:22:23 UTC, Steven Schveighoffer wrote: On Friday, 5 March 2021 at 02:13:39 UTC, Jack wrote: something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent the wheel [1

Re: Is there any generic iteration function that stops at first match?

2021-03-04 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 02:43:36 UTC, H. S. Teoh wrote: On Fri, Mar 05, 2021 at 02:13:39AM +, Jack via Digitalmars-d-learn wrote: something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent

Can't I allocate at descontructor?

2021-03-04 Thread Jack via Digitalmars-d-learn
The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why? core.exception.InvalidMemoryOperationError@src\core\exception.d(647): Invalid memory operation import std.stdio; int main() {

Re: Is there any generic iteration function that stops at first match?

2021-03-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 5 March 2021 at 02:13:39 UTC, Jack wrote: something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent the wheel [1]: https://devdocs.io/d/std_algorithm_iteration#filter std.algorithm

Re: How do I run multiple unittests with rdmd?

2021-03-04 Thread Anthony via Digitalmars-d-learn
On Friday, 5 March 2021 at 02:08:37 UTC, H. S. Teoh wrote: In the latter case, you could just use `rdmd -unittest -i -run main.d` (replace `main.d` with whatever source file contains main()) to automatically compile all modules including their unittests *and* run 'em all in one shot. I didn't

Re: D's Continous Changing

2021-03-04 Thread Mike Parker via Digitalmars-d-learn
On Friday, 5 March 2021 at 03:35:31 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 03:32:35 UTC, harakim wrote: correct version of compiler, but this will be helpful. Is it possible to download old versions of the compiler somewhere? From this page you can follow a trail all the way back

Re: D's Continous Changing

2021-03-04 Thread Mike Parker via Digitalmars-d-learn
On Friday, 5 March 2021 at 03:32:35 UTC, harakim wrote: correct version of compiler, but this will be helpful. Is it possible to download old versions of the compiler somewhere? From this page you can follow a trail all the way back to 0.00 if you're so inclined: https://dlang.org/changelo

Re: D's Continous Changing

2021-03-04 Thread harakim via Digitalmars-d-learn
``` "toolchainRequirements": { "frontend": "==2.096" }, ``` Thanks! I didn't know you could specify a toolchain version. I agree it would be cool if it automatically downloaded the correct version of compiler, but this will be helpful. Is it possible to downloa

Re: Is there any generic iteration function that stops at first match?

2021-03-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 05, 2021 at 02:13:39AM +, Jack via Digitalmars-d-learn wrote: > something like filter[1] but that stops at first match? are there any > native functions for this in D or I have to write one? just making > sure to not reinvent the wheel [...] Why not just .front? E.g.: int

Is there any generic iteration function that stops at first match?

2021-03-04 Thread Jack via Digitalmars-d-learn
something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent the wheel [1]: https://devdocs.io/d/std_algorithm_iteration#filter

Re: How do I run multiple unittests with rdmd?

2021-03-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 05, 2021 at 01:47:41AM +, Anthony via Digitalmars-d-learn wrote: > Hello, > > I'm trying to run multiple unittest files with rdmd. > So far I use `find` to just pipe in the files. Eg: > > > time find source -name *__tests.d -exec rdmd -unittest --main > -I../libprelude/source -I.

How do I run multiple unittests with rdmd?

2021-03-04 Thread Anthony via Digitalmars-d-learn
Hello, I'm trying to run multiple unittest files with rdmd. So far I use `find` to just pipe in the files. Eg: time find source -name *__tests.d -exec rdmd -unittest --main -I../libprelude/source -I../libparser/source -I../libgeometry/source -Isource {} \; Is there an easier way to do this?

Re: dub support for Mac M1?

2021-03-04 Thread kinke via Digitalmars-d-learn
On Thursday, 4 March 2021 at 22:30:17 UTC, tastyminerals wrote: I got a company MacBook with M1 chip and gradually migrate all the stuff from Linux machine. I got precompiled ldc binary installed without any problem now is the time for dub since I have couple of D projects I use at work and all

Re: dub support for Mac M1?

2021-03-04 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 4 March 2021 at 22:30:17 UTC, tastyminerals wrote: I got a company MacBook with M1 chip and gradually migrate all the stuff from Linux machine. I got precompiled ldc binary installed without any problem now is the time for dub since I have couple of D projects I use at work and all

dub support for Mac M1?

2021-03-04 Thread tastyminerals via Digitalmars-d-learn
I got a company MacBook with M1 chip and gradually migrate all the stuff from Linux machine. I got precompiled ldc binary installed without any problem now is the time for dub since I have couple of D projects I use at work and all of them use dub. I can only see the dub-v1.23.0-osx-x86_64.tar

Re: Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 4 March 2021 at 15:19:16 UTC, frankp wrote: On Thursday, 4 March 2021 at 14:54:11 UTC, frankp wrote: I give up. This makes no sense. I just accept this is the work of gremlins. I revert to a plain alias and an enum. Sorry for wasting your time. Not gremlins after all. It was sim

Re: Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread frankp via Digitalmars-d-learn
On Thursday, 4 March 2021 at 14:54:11 UTC, frankp wrote: I give up. This makes no sense. I just accept this is the work of gremlins. I revert to a plain alias and an enum. Sorry for wasting your time. Not gremlins after all. It was simply a matter of the compiler pointing to the wrong line.

Re: Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread frankp via Digitalmars-d-learn
On Thursday, 4 March 2021 at 14:42:16 UTC, frankp wrote: However, the compiler complains if the struct is called "cycle_t". That's curious. Is that a reserved name? I don't import anything by that name. Not to my knowledge at least - I'm strictly using named imports. False alarm. If I remove t

Re: Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread frankp via Digitalmars-d-learn
On Thursday, 4 March 2021 at 14:31:23 UTC, Simen Kjærås wrote: On Thursday, 4 March 2021 at 13:58:48 UTC, frankp wrote: Hi all, I want to make an opaque type that simply contains an integer with some immutable constants and toString pretty printing. Like this: struct Foo_t { private long

Re: Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread frankp via Digitalmars-d-learn
On Thursday, 4 March 2021 at 14:18:07 UTC, harakim wrote: [...] This is the text of my program import std.stdio; struct Foo_t { private long foo; alias foo this; static immutable long Inf = long.max; //1) void toString(...){ writeln(foo); } } void main() { Foo_t sampl

Re: Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 4 March 2021 at 13:58:48 UTC, frankp wrote: Hi all, I want to make an opaque type that simply contains an integer with some immutable constants and toString pretty printing. Like this: struct Foo_t { private long foo; alias foo this; static immutable long Inf = long.max

Re: Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread harakim via Digitalmars-d-learn
On Thursday, 4 March 2021 at 13:58:48 UTC, frankp wrote: Hi all, I want to make an opaque type that simply contains an integer with some immutable constants and toString pretty printing. Like this: struct Foo_t { private long foo; alias foo this; static immutable long Inf = long.max

Opaque type (struct) with a static immutable fails to compile without constructor - why?

2021-03-04 Thread frankp via Digitalmars-d-learn
Hi all, I want to make an opaque type that simply contains an integer with some immutable constants and toString pretty printing. Like this: struct Foo_t { private long foo; alias foo this; static immutable long Inf = long.max; //1) void toString(...){} } On dmd 2.092.1 this fai

Re: Vibe.d tutorial

2021-03-04 Thread Imperatorn via Digitalmars-d-learn
On Monday, 1 March 2021 at 22:25:39 UTC, Rey Valeza wrote: Hi, I wrote a tutorial on Vibe.d while trying to re-learn Vibe.d. I find that most of Kai Nacke's book need updating, so I wrote a tutorial while trying to re-learn it. Here it is. https://github.com/reyvaleza/vibed/commit/27ec3678f25

Re: D's Continous Changing

2021-03-04 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 3 March 2021 at 23:30:20 UTC, harakim wrote: Contrast to me trying to figure out how to format a number in binary. format!"%b"(number) does not work but is very similar to what is suggested in the documentation. I was able to figure out it's format("%b", number) but it took a few

Re: D's Continous Changing

2021-03-04 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 3 March 2021 at 23:30:20 UTC, harakim wrote: Every time I come back to a D program I wrote over a year ago, it seems like there are numerous breaking changes and it takes me a while to get it to compile again. I am porting a large code base from Extended Pascal to D and I know t

Re: D's Continous Changing

2021-03-04 Thread user1234 via Digitalmars-d-learn
On Thursday, 4 March 2021 at 09:21:12 UTC, Siemargl wrote: On Thursday, 4 March 2021 at 06:43:57 UTC, user1234 wrote: otherwise another solution is to check every two monthes the sanity of your projects. E.g a montly cronjob on a CI service and that uses latest DMD Docker image. If it fails y

Re: D's Continous Changing

2021-03-04 Thread Siemargl via Digitalmars-d-learn
On Thursday, 4 March 2021 at 06:43:57 UTC, user1234 wrote: otherwise another solution is to check every two monthes the sanity of your projects. E.g a montly cronjob on a CI service and that uses latest DMD Docker image. If it fails you got an email... It certainly cooler to take 5 mins every