Re: Compile Time Fun Time

2019-02-24 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 25 February 2019 at 06:51:20 UTC, Yevano wrote: This only works for at most 3 parameter delegates. If I want to add more, I have to linearly add more static ifs in the obvious way. However, I believe I can make this function scalable using string mixins and other magic. Any insight

Re: DMD2 vs LDC2 inliner

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 04:08:38 UTC, Jonathan M Davis wrote: One issue that's commonly brought up about dmd's inliner is that it's in the front-end, which apparently is a poor way to do inlining. One side effect of that though would be that unless the ldc folks go to extra effort to

Re: DMD2 vs LDC2 inliner

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 02:49:36 UTC, James Blachly wrote: Any ideas why DMD2 cannot inline this, but LDC2 has no problem doing so -- or suggestions for what I can do to make DMD2 inline it? Alternatively, I could version(DigitalMars) and version(LDC), but AFAICT this requires me to

Re: Compile Time Fun Time

2019-02-24 Thread Yevano via Digitalmars-d-learn
On Monday, 25 February 2019 at 07:03:21 UTC, Nicholas Wilson wrote: import std.traits; Abstraction L(alias f)() { alias Args = Parameters!f; Args v; foreach(i; 0 .. v.length) v[i] = new Variable; auto _f = f(v); auto abstraction = new Abstraction(v[$-1],_f);

Re: Compile Time Fun Time

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 06:51:20 UTC, Yevano wrote: I am writing a domain specific language of sorts in D for the lambda calculus. One of my requirements is that I should be able to generate expressions like this: new Abstraction(v1, M) like this: L!(x => M) It is common to want to

Compile Time Fun Time

2019-02-24 Thread Yevano via Digitalmars-d-learn
I am writing a domain specific language of sorts in D for the lambda calculus. One of my requirements is that I should be able to generate expressions like this: new Abstraction(v1, M) like this: L!(x => M) It is common to want to write things like L!(x => L!(y => M)) but it is much nicer

Re: Disable dub from checking internet before building

2019-02-24 Thread drug via Digitalmars-d-learn
On 25.02.2019 1:51, 0x wrote: How to disable dub from checking internet before building, it's slowing down build whenever it does this. `--skip-registry=all` let you avoid checking of all dependencies (https://dub.pm/commandline)

Re: Disable dub from checking internet before building

2019-02-24 Thread Benjamin Schaaf via Digitalmars-d-learn
On Sunday, 24 February 2019 at 22:51:45 UTC, 0x wrote: How to disable dub from checking internet before building, it's slowing down build whenever it does this. Its not too well described but --nodeps skips dependency resolution (just uses the locked dependencies). Since dub only

Re: DMD2 vs LDC2 inliner

2019-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 24, 2019 7:49:36 PM MST James Blachly via Digitalmars-d- learn wrote: > Any ideas why DMD2 cannot inline this, but LDC2 has no problem doing so > -- or suggestions for what I can do to make DMD2 inline it? The unfortunate reality of the matter is that dmd's inliner is very

DMD2 vs LDC2 inliner

2019-02-24 Thread James Blachly via Digitalmars-d-learn
Any ideas why DMD2 cannot inline this, but LDC2 has no problem doing so -- or suggestions for what I can do to make DMD2 inline it? Alternatively, I could version(DigitalMars) and version(LDC), but AFAICT this requires me to duplicate the entire template, because I cannot figure out how to

Re: Why is SwitchError an error and how is it unsafe to continue after catching it?

2019-02-24 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 24 February 2019 at 10:53:09 UTC, aliak wrote: Because from what I understand, an Error is something you should not be catching and represents something unrecoverable. And it the docs say that it's unsafe to continue execution. But the following code is very recoverable and I don't

Re: How to call other variadic function with the same arguments?

2019-02-24 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote: Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... } If you must use C-style variadic arguments, then your

Re: Why is SwitchError an error and how is it unsafe to continue after catching it?

2019-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 24, 2019 5:42:32 AM MST Dennis via Digitalmars-d-learn wrote: > On Sunday, 24 February 2019 at 10:53:09 UTC, aliak wrote: > > But the following code is very recoverable and I don't see how > > > it's unsafe to continue executing: > There is no guarantee that a final switch

Disable dub from checking internet before building

2019-02-24 Thread 0xFFFFFFFF via Digitalmars-d-learn
How to disable dub from checking internet before building, it's slowing down build whenever it does this.

Converting stringized array to dstring[]

2019-02-24 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi everyone, I've stumbled on another possible bug: - import std.stdio; import std.conv; void main() { "[ \"test\" ]".to!(dstring[]).writeln; } - It gives following error: - /dlang/dmd/linux/bin64/../../src/phobos/std/conv.d(222): Error:

Re: How to call other variadic function with the same arguments?

2019-02-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote: Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... } I don’t know if you can, but if at least g is a variadic

Re: Where are declared and how to make build these c identifiers?

2019-02-24 Thread Cleverson Casarin Uliana via Digitalmars-d-learn
Em 24/02/2019 11:34, Adam D. Ruppe via Digitalmars-d-learn escreveu: Those don't have printable characters associated, so they all look the same. Try writeln(cast(int) code)  - casting it to int so you can see the number - and you should see the different results. Or even  

Re: Where are declared and how to make build these c identifiers?

2019-02-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 24 February 2019 at 14:34:45 UTC, Adam D. Ruppe wrote: supported key list: well, obviously, plus the normal printable characters like letters, numbers, tab, space, enter... but those have char values so no need to list in an enum.

Re: How to call other variadic function with the same arguments?

2019-02-24 Thread JN via Digitalmars-d-learn
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote: Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... } void f(A...)(A a) { foreach(t; a)

Re: Where are declared and how to make build these c identifiers?

2019-02-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 24 February 2019 at 12:37:21 UTC, Cleverson Casarin Uliana wrote: OK, it built the executable, but it doesn't work for every key, e.g. when I try with arrow and function keys, it always returns the same symbol, so I'm unable to distinguish what key has been pressed: Those don't

How to call other variadic function with the same arguments?

2019-02-24 Thread Victor Porton via Digitalmars-d-learn
Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... }

Re: How to use math functions in dcompute?

2019-02-24 Thread naetherm via Digitalmars-d-learn
On Tuesday, 25 September 2018 at 05:18:55 UTC, Sobaya wrote: On Thursday, 20 September 2018 at 12:48:14 UTC, Nicholas Wilson wrote: On Thursday, 20 September 2018 at 12:43:02 UTC, Nicholas Wilson wrote: Hmm, I can reproduce. Will look into it. pragma(LDC_intrinsic, "llvm.nvvm.cos.approx.f")

Re: Where are declared and how to make build these c identifiers?

2019-02-24 Thread Cleverson Casarin Uliana via Digitalmars-d-learn
Em 24/02/2019 00:19, Adam D. Ruppe via Digitalmars-d-learn escreveu: You just need to pass the terminal.d file to your build too. dmd yourfile.d terminal.d so it knows to include it. OK, it built the executable, but it doesn't work for every key, e.g. when I try with arrow and function keys,

Re: Why is SwitchError an error and how is it unsafe to continue after catching it?

2019-02-24 Thread Dennis via Digitalmars-d-learn
On Sunday, 24 February 2019 at 10:53:09 UTC, aliak wrote: But the following code is very recoverable and I don't see how it's unsafe to continue executing: There is no guarantee that a final switch throws an Error. From what I've heard of Walter [1] (though I can't find it in the spec), the

Re: Odd behavior of darray.dup

2019-02-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 24 February 2019 at 12:10:22 UTC, Bastiaan Veelo wrote: 1) You get "immutable(Color)(#{overlap raw, colors})" on immutable Color because the `Color.toString()` method is not const (corrected in the Gist). This is a bug in pixelperfectengine. Likewise, getters like `green()` should

Re: Odd behavior of darray.dup

2019-02-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 23 February 2019 at 23:35:14 UTC, solidstate1991 wrote: On Saturday, 23 February 2019 at 19:21:10 UTC, Bastiaan Veelo wrote: It works for me: https://run.dlang.io/gist/473b0021487275751accaebeb00be05c -- Bastiaan Still no luck, not even with memcpy. There's even more mystery

Re: Why is SwitchError an error and how is it unsafe to continue after catching it?

2019-02-24 Thread Alex via Digitalmars-d-learn
On Sunday, 24 February 2019 at 10:53:09 UTC, aliak wrote: Because from what I understand, an Error is something you should not be catching and represents something unrecoverable. And it the docs say that it's unsafe to continue execution. But the following code is very recoverable and I don't

Why is SwitchError an error and how is it unsafe to continue after catching it?

2019-02-24 Thread aliak via Digitalmars-d-learn
Because from what I understand, an Error is something you should not be catching and represents something unrecoverable. And it the docs say that it's unsafe to continue execution. But the following code is very recoverable and I don't see how it's unsafe to continue executing: import