Re: Memory allocation

2021-02-23 Thread David via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 06:14:58 UTC, Imperatorn wrote: On Tuesday, 23 February 2021 at 19:44:39 UTC, David wrote: Not sure if `learn` is the right topic or not to post this.. I've been going through Bob Nystrom's "Crafting Interpreters" for a bit of fun and over the weekend put toge

Re: Compile-Time Function Parameters That Aren't Types?

2021-02-23 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 24, 2021 at 03:52:57AM +, Kyle Ingraham via Digitalmars-d-learn wrote: [...] > I was under the impression that compile-time or template parameters > were only for types. In D, template parameters can take not only types, but almost any type (provided they are constructible at comp

Re: Memory allocation

2021-02-23 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 19:44:39 UTC, David wrote: Not sure if `learn` is the right topic or not to post this.. I've been going through Bob Nystrom's "Crafting Interpreters" for a bit of fun and over the weekend put together a toy allocator in D - free and gc not yet done. It's single

Re: Compile-Time Function Parameters That Aren't Types?

2021-02-23 Thread Kyle Ingraham via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 03:57:37 UTC, Adam D. Ruppe wrote: On Wednesday, 24 February 2021 at 03:52:57 UTC, Kyle Ingraham wrote: The part that got my attention was `bool isBGR`. I was under the impression that compile-time or template parameters were only for types. No, you can pass

Re: Compile-Time Function Parameters That Aren't Types?

2021-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 03:52:57 UTC, Kyle Ingraham wrote: The part that got my attention was `bool isBGR`. I was under the impression that compile-time or template parameters were only for types. No, you can pass almost anything to them. https://dlang.org/spec/template.html#templat

Compile-Time Function Parameters That Aren't Types?

2021-02-23 Thread Kyle Ingraham via Digitalmars-d-learn
I was reading the code for the DCV library and came across this function: https://github.com/libmir/dcv/blob/master/source/dcv/imgproc/color.d#L128 Here is a shortened form: [return type] rgbbgr2gray(bool isBGR, V)([run-time parameters]){[implementation]} and an example call: rgbbgr2gray!(tr

Re: Can Metaprogramming Help Here?

2021-02-23 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 23, 2021 at 10:24:50PM +, Mike Brown via Digitalmars-d-learn wrote: > Hi all, > > Im porting some C++ code, which has a mess of a section that > implements prime number type id's. I've had to smother it to death > with test cases to get it reliable, I think metaprogramming that D

Can Metaprogramming Help Here?

2021-02-23 Thread Mike Brown via Digitalmars-d-learn
Hi all, Im porting some C++ code, which has a mess of a section that implements prime number type id's. I've had to smother it to death with test cases to get it reliable, I think metaprogramming that D provides is the better solution - Id rather not reimplement that C++ mess ideally. A sim

Re: Is this a good way to do lazy evaluation?

2021-02-23 Thread Ali Çehreli via Digitalmars-d-learn
On 2/22/21 2:00 PM, Jack wrote: > C defValue() { return C.a; } Yes, putting the expression in a function is the way I know for lazy evaluation. Ali

Memory allocation

2021-02-23 Thread David via Digitalmars-d-learn
Not sure if `learn` is the right topic or not to post this.. I've been going through Bob Nystrom's "Crafting Interpreters" for a bit of fun and over the weekend put together a toy allocator in D - free and gc not yet done. It's single threaded and unsurprisingly faster than malloc for small ob

Re: ldc on a raspberry pi 3 running freebsd

2021-02-23 Thread Decabytes via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 15:11:32 UTC, Adam D. Ruppe wrote: On Tuesday, 23 February 2021 at 14:56:45 UTC, Decabytes wrote: It is often called `ldc2` so give that a try. btw I run gdc on my raspberry pi 3 from the raspbian distro package and it is pretty nice too. though ldc will have

Re: ldc on a raspberry pi 3 running freebsd

2021-02-23 Thread Decabytes via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 15:15:56 UTC, Steven Schveighoffer wrote: On 2/23/21 9:56 AM, Decabytes wrote: Found this on the internet: https://forums.freebsd.org/threads/list-of-the-installed-files-of-a-package.66372/ looks like: pkg info -l name-of-package It should show you were it p

Re: ldc on a raspberry pi 3 running freebsd

2021-02-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/23/21 9:56 AM, Decabytes wrote: I've been playing around in D for a bit and I'm enjoying it so far. I've also been testing out freebsd on a Raspberry Pi 3. I noticed that there is actually a package for LDC on the raspberry pi 3, and thought it would be fun to play around with D on an ARM

Re: ldc on a raspberry pi 3 running freebsd

2021-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 14:56:45 UTC, Decabytes wrote: I installed it with "pkg install ldc", but embarrassingly I'm not actually sure where the compiler is. ldc isn't a recognized action on the command line It is often called `ldc2` so give that a try. btw I run gdc on my raspberry p

ldc on a raspberry pi 3 running freebsd

2021-02-23 Thread Decabytes via Digitalmars-d-learn
I've been playing around in D for a bit and I'm enjoying it so far. I've also been testing out freebsd on a Raspberry Pi 3. I noticed that there is actually a package for LDC on the raspberry pi 3, and thought it would be fun to play around with D on an ARM platform. I installed it with "pkg

Re: How to get output of piped process?

2021-02-23 Thread Imperatorn via Digitalmars-d-learn
On Monday, 22 February 2021 at 13:23:40 UTC, Danny Arends wrote: On Friday, 19 February 2021 at 15:39:25 UTC, kdevel wrote: [...] Perhaps a bit late, but this is how I deal with pipes and spawnShell. Read one byte at a time from stdout and stderr: https://github.com/DannyArends/DaNode/blob/

Re: Why does this not pass

2021-02-23 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 09:21:44 UTC, Imperatorn wrote: Why does all these pass: static assert(is(ElementEncodingType!(char[]) == char)); static assert(is(ElementEncodingType!(wstring) == immutable(wchar))); static assert(is(ElementEncodingType!(byte[]) == byte)); static

Why does this not pass

2021-02-23 Thread Imperatorn via Digitalmars-d-learn
Why does all these pass: static assert(is(ElementEncodingType!(char[]) == char)); static assert(is(ElementEncodingType!(wstring) == immutable(wchar))); static assert(is(ElementEncodingType!(byte[]) == byte)); static assert(is(ElementEncodingType!(ubyte[]) == ubyte)); auto ra