On Monday, 21 February 2022 at 20:18:46 UTC, Paul Backus wrote:
This is a long-standing limitation of the D compiler's template
argument deduction: it cannot "see through" `alias` templates
to deduce the underlying type.
Oh, that’s an unfortunate limitation but at least there’s a
workaround.
See https://run.dlang.io/is/hNaSFh:
```d
import std.sumtype;
struct Unit {}
alias Option(T) = SumType!(T, Unit);
void foobar(T)(Option!T option) {}
void main() {
foobar(Option!int(123));
}
```
If you run this, the compiler should emit this error:
```d
onlineapp.d(14): Error: template `on
On Sunday, 27 October 2019 at 19:54:06 UTC, Simen Kjærås wrote:
It's a bug:
interface A {
interface B : A {
class C : B {
}
}
// Fails: no property 'C' for type 'foo.A.B'
void inside(A.B.C c) { }
}
// Works
void outside(A.B.C c) { }
https://issues.dlang.org/show_
Hello! See snippet:
---
interface AST
{
static interface Expr : AST
{
final static class Name : Expr
{
override void accept(AST.Visitor v) {
v.visitName(this); }
}
}
final static class Visitor
{
void visitName(AST.Expr.Name name);
Hello. My problem is exactly what it says on the title: my dmd
(windows 7, x64) doesn't seem to have -fPIC:
---
dmd -fPIC
Error: unrecognized switch '-fPIC'
run `dmd` to print the compiler manual
run `dmd -man` to open browser on manual
---
`dmd --help` also doesn't have anythin
Forgot to say: dmd v2.088.0. Also, weirdly enough, `dmd
--version` outputs `DMD32 D Compiler v2.088.0-dirty`. Why is
"dirty" there?
On Friday, 21 June 2019 at 15:54:35 UTC, Adam D. Ruppe wrote:
On Friday, 21 June 2019 at 15:42:56 UTC, Emmanuelle wrote:
[...]
This sounds very similar to something I hacked together a while
ago and recently wrote about making cleaner code:
https://forum.dlang.org/post/ekbyseslunvmudkhl...@
On Thursday, 20 June 2019 at 20:38:48 UTC, Dennis wrote:
On Thursday, 20 June 2019 at 19:09:11 UTC, Emmanuelle wrote:
Is there any trait or Phobos function for transforming a
function/delegate/lambda/whatever's body into a string
suitable for `mixin(...)`? For example:
See:
https://forum.dlan
Hello!
Is there any trait or Phobos function for transforming a
function/delegate/lambda/whatever's body into a string suitable
for `mixin(...)`? For example:
---
__traits(getBody, (int a, int b) => a + b); // returns "(int a,
int b) => a + b"
// o
On Tuesday, 18 June 2019 at 21:57:32 UTC, Jonathan M Davis wrote:
-snip-
Thank you, it's clear to me now :)
Hi, I've been reading about DIP25 and DIP1000 and I'm not quite
sure if I understand the difference between the two—is DIP1000
supposed to be a rework of DIP25? And what's the difference
between `return ref` and `return scope`? Also, will there be any
compiler version where `-preview=dip25` and
On Saturday, 15 June 2019 at 16:29:29 UTC, Rémy Mouëza wrote:
I don't know if we can tell this is a compiler bug. The same
behavior happens in Python. The logic being variable `x` is
captured by the closure. That closure's context will contain a
pointer/reference to x. Whenever x is updated out
On Saturday, 15 June 2019 at 00:30:43 UTC, Adam D. Ruppe wrote:
On Saturday, 15 June 2019 at 00:24:52 UTC, Emmanuelle wrote:
Is it a compiler bug?
Yup, a very longstanding bug.
You can work around it by wrapping it all in another layer of
function which you immediately call (which is fairly
Take a look at this code:
---
import std.stdio;
void main()
{
alias Func = void delegate(int);
int[][] nums = new int[][5];
Func[] funcs;
foreach (x; 0 .. 5) {
funcs ~= (int i) { nums[x] ~= i; };
}
foreach (i, func; funcs) {
func(cast(int) i);
}
On Monday, 22 April 2019 at 19:32:27 UTC, Adam D. Ruppe wrote:
On Monday, 22 April 2019 at 19:02:57 UTC, Emmanuelle wrote:
Hello! Does `__traits(getAttributes, ...)` return UDAs in the
order they were declared in the source code, or is it
unspecified?
I think that is defined:
https://dlang.o
Hello! Does `__traits(getAttributes, ...)` return UDAs in the
order they were declared in the source code, or is it unspecified?
16 matches
Mail list logo