On Thursday, 12 May 2022 at 18:07:05 UTC, H. S. Teoh wrote:
On Thu, May 12, 2022 at 09:04:09AM -0700, Ali Çehreli via
Digitalmars-d-learn wrote:
Error: template `std.algorithm.iteration.sum` cannot deduce
function from
argument types `!()(int[3])`
On Wednesday, 11 May 2022 at 15:10:28 UTC, Tejas wrote:
That'll be true the day when `@safe` becomes the default...
Until then, I'll atleast do `@safe:` on top of every module :)
`@safe:` is actually a bad idea if you're writing templated code,
because it turns inference of `@system` into a
On Saturday, 7 May 2022 at 20:24:39 UTC, jmh530 wrote:
On Saturday, 7 May 2022 at 18:46:03 UTC, Paul Backus wrote:
```d
import std.functional: partial;
enum int a = 1;
alias foo2 = partial!(foo, a);
```
[snip]
Thanks. This is basically equivalent to
```d
int foo(int a)(int x) { return x +
On Saturday, 7 May 2022 at 18:36:40 UTC, jmh530 wrote:
In the code below, there is a two parameter function `foo` and
an override of it with only one parameter. In the override
case, I force the second one to be 1, but ideally there should
be a way to specify it at compile-time.
Have you
On Monday, 25 April 2022 at 08:54:52 UTC, Chris Katko wrote:
D
alias sPair = Typedef!pair; // pair of xy in screen space
coordinates
alias vPair = Typedef!pair; // pair of xy in viewport space
coordinates
//etc
This doesn't do what you think it does. Both `sPair` and `vPair`
are
On Thursday, 21 April 2022 at 21:02:47 UTC, JG wrote:
Hi,
Could someone possibly help me to understand why the commented
line doesn't compile?
```d
import std;
struct MapResult(R,F)
{
R r;
const F f;
auto empty() { return r.empty; }
auto front() { return f(r.front); }
On Thursday, 21 April 2022 at 12:54:12 UTC, Dennis wrote:
On Thursday, 21 April 2022 at 12:41:08 UTC, WebFreak001 wrote:
which I think is a little bug-prone, but at least that would
solve my issues.
What issue do you have with it returning `true`?
Presumably the problem is that if you write
On Tuesday, 19 April 2022 at 13:36:26 UTC, Andrey Zherikov wrote:
I want to migrate my library API from standalone function that
takes delegate as argument to a template member function that
takes delegate as a template parameter but compiler errors out.
Here is code example:
```d
import
On Friday, 15 April 2022 at 18:11:11 UTC, BoQsc wrote:
Let's say I have this example program.
I want to get the arguments of all the `some_function();` in
the whole program.
**Even if the scope of the function call is never executed.**
(Ex. due to IF statement being negative.)
You can't do
On Monday, 11 April 2022 at 12:12:39 UTC, Salih Dincer wrote:
It worked for me in a different way.
1 is (about to be) alive!
2 is (already) dead.
2 is (already) dead.
2 is (already) dead.
2 is (already) dead.
2 is (already) dead.
Hello D!
1 is (already) dead.
Because I changed the code
On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer
wrote:
I'd implement it probably like this (for D2):
```d
auto drop(T)(ref T[] arr, T which)
{
import std.algorithm, std.range;
auto f = arr.find(which);
debug if(f.empty) throw ...;
auto result = arr.front;
arr =
On Monday, 4 April 2022 at 12:57:28 UTC, V3nom wrote:
define the lists:
(define liste (cons 10(cons 20(cons 30(cons 40 ' ())
(define liste2 (cons 20(cons 30(cons 10(cons 40 ' ())
define the "function":
(define (listapp list1 list2)(
if (null? (cdr list1))
On Sunday, 3 April 2022 at 13:50:28 UTC, Salih Dincer wrote:
Hi all,
Do you have a good example of how const variables actually work?
So I'm not talking about system resources and programming
errors. I want to say it's good. Because if everything works
without it, why does it exist?
This
On Saturday, 2 April 2022 at 14:49:15 UTC, Vijay Nayar wrote:
On Saturday, 2 April 2022 at 14:35:10 UTC, Vijay Nayar wrote:
The `tryMatch` method fails to compile, and instead I get the
following error:
```d
/dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(2004):
Error: static assert:
On Thursday, 31 March 2022 at 19:44:23 UTC, WhatMeWorry wrote:
Is there a way to programmatically determine the exact maximum
memory size available to the DRuntime’s array implementation?
Closest you can get is probably [`GC.stats`][1], which will give
you the total amount of free memory
On Tuesday, 29 March 2022 at 19:55:52 UTC, Andrey Zherikov wrote:
I have a function below (just an example). What's the
recommended way to unit-test it for all `version` cases?
```d
void f()
{
import std.stdio: writeln;
version(foo)
writeln("foo");
else
On Saturday, 12 March 2022 at 19:00:23 UTC, Paul Backus wrote:
On Saturday, 12 March 2022 at 18:49:32 UTC, Anonymouse wrote:
Currently I'm testing if a function that takes the address of
the member compiles, and I think it works, but like with
everything `__traits(compiles)` it strikes me as
On Saturday, 12 March 2022 at 18:49:32 UTC, Anonymouse wrote:
Currently I'm testing if a function that takes the address of
the member compiles, and I think it works, but like with
everything `__traits(compiles)` it strikes me as it might not
be the right way to go about things.
It sounds
On Tuesday, 8 March 2022 at 17:47:47 UTC, BoQsc wrote:
Premise: In D language, only one main(){} function can exist in
a program.
Having two `main()` functions throws an error.
Let's say I want to use some functionality of another program,
but it has a `main(){}`
function. How can I import
On Tuesday, 1 March 2022 at 14:51:47 UTC, wjoe wrote:
Hello,
what's a dual context as in the deprecation message?
It means you have a struct or class member function that accesses
its calling context via a template alias parameter.
See this bug report for more information:
On Tuesday, 1 March 2022 at 16:40:50 UTC, Paul Backus wrote:
It's a bug in druntime. `destroy` needs to reinterpret the
class reference as a `void*` to pass it to `rt_finalize`:
https://github.com/dlang/druntime/blob/v2.098.1/src/object.d#L4209
However, `cast(void*)` is not the correct way
On Tuesday, 1 March 2022 at 04:59:49 UTC, Mike Parker wrote:
On Tuesday, 1 March 2022 at 04:29:56 UTC, cc wrote:
```d
struct A {}
class B {
A opCast(T : A)() {
return A();
}
}
void main() {
auto b = new B();
destroy(b);
}
```
fails with
```
On Friday, 25 February 2022 at 23:34:59 UTC, kdevel wrote:
What about this:
```d
module model; // model.d
import std.file : read; // this line provokes the error
private int read (string filename) // now it's private
{
import std.file;
auto data = std.file.read (filename);
return 0;
On Friday, 25 February 2022 at 23:05:00 UTC, kdevel wrote:
It seems the template parameter f becomes not aliased to
model.read in the presence of the selective import. Bug or
feature?
I'd call this a bug. Currently, selective imports are implemented
using `alias`es under the hood, which
On Friday, 25 February 2022 at 19:06:25 UTC, Ali Çehreli wrote:
On 2/25/22 08:24, Paul Backus wrote:
> I've seen `.stringof` give inconsistent results. (E.g.,
> https://issues.dlang.org/show_bug.cgi?id=18269)
That must be a part of the reasons why Adam D Ruppe repeats
that .stringof should
On Friday, 25 February 2022 at 14:25:22 UTC, Andrey Zherikov
wrote:
Another interesting observation - is there any explanation why
`typeof` returns different results for generated `opAssign`?
[...]
If I move `foreach` loop into a function (e.g. `main`) then the
first pragma prints the same
On Tuesday, 22 February 2022 at 12:48:21 UTC, frame wrote:
What am I missing here? Is this some UTF conversion issue?
```d
string a;
char[] b;
pragma(msg, typeof(a.take(1).front)); // dchar
pragma(msg, typeof(b.take(1).front)); // dchar
```
This is a feature of the D standard library known
On Monday, 21 February 2022 at 18:43:18 UTC, Emmanuelle wrote:
If you run this, the compiler should emit this error:
```d
onlineapp.d(14): Error: template `onlineapp.foobar` cannot
deduce function from argument types `!()(SumType!(int, Unit))`
onlineapp.d(8):Candidate is:
On Tuesday, 8 February 2022 at 21:58:49 UTC, H. S. Teoh wrote:
On Tue, Feb 08, 2022 at 09:47:13PM +, Paul Backus via
Digitalmars-d-learn wrote: [...]
The `alias` and the `enum` just make the code a little nicer
to read by letting you write `Unit` instead of `void[0]` and
`unit` instead
On Tuesday, 8 February 2022 at 21:08:47 UTC, tastyminerals wrote:
https://forum.dlang.org/post/mailman.1072.1581112984.31109.digitalmars-d-le...@puremagic.com
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
On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote:
It claims that the D calling convention matches C. But it seems
that the arguments are pushed in order whereas C does it in
reverse order and the -218697648 value is indeed my 3rd string
pointer.
Windows has two calling conventions for
On Thursday, 20 January 2022 at 13:19:06 UTC, Sergey wrote:
https://forum.dlang.org/post/17nwtnp4are5q$.1ddtvmj4e23iy@40tude.net
On Tuesday, 10 May 2005 at 01:06:14 UTC, Derek Parnell wrote:
[...]
Thanks a lot for your explanation.
I started to learn D language recently and I have
On Tuesday, 18 January 2022 at 04:42:45 UTC, frame wrote:
At the very top of my module I have this declaration:
```d
static if (__VERSION__ >= 2098)
{
alias Foo = TypeA;
}
else
{
alias Foo = TypeB;
}
```
No problem inside the module itself but this doesn't work when
imported from
On Monday, 17 January 2022 at 10:24:06 UTC, forkit wrote:
so I'm wondering why the code below prints:
1 2 3 4
and not
1 2 3 4 5
as I would expect.
foreach (value; 1..5) writef("%s ", value);
This kind of half-open interval, which includes the lower bound
but excludes the upper bound, is
On Sunday, 16 January 2022 at 18:22:04 UTC, Steven Schveighoffer
wrote:
Does this work normally? The memory error handler for Linux
jumps through a lot of hoops to be able to throw an error from
a signal handler. See
https://github.com/dlang/druntime/blob/master/src/etc/linux/memoryerror.d
On Sunday, 16 January 2022 at 15:15:07 UTC, Hipreme wrote:
Is there some way to throw a stack trace when killing the
program from the CTRL+C from the terminal?
It would help a lot into debugging occasional infinity loops
On POSIX, you can use the `sigaction` function to install a
signal
On Saturday, 15 January 2022 at 01:49:14 UTC, forkit wrote:
I want int[][] like this -> [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
Any help will be appreciated.
note: to2Darray is not a valid statement ;-)
// ---
module test;
import std;
void main()
{
int[][]
On Wednesday, 12 January 2022 at 00:45:23 UTC, H. S. Teoh wrote:
IMNSHO, that @trusted lambda thing is an anti-pattern that
should be avoided, needless to say already promoted. It's
papering over a problem that ought to be fixed instead of being
pushed under the rug.
There's nothing wrong
On Tuesday, 11 January 2022 at 21:38:58 UTC, forkit wrote:
On Tuesday, 11 January 2022 at 14:54:51 UTC, Paul Backus wrote:
..
If you compile with -preview=dip1000, the compiler will
actually keep track of which pointers point to stack memory,
and will allow your original code. But
On Tuesday, 11 January 2022 at 10:57:28 UTC, forkit wrote:
On Monday, 10 January 2022 at 03:21:46 UTC, Paul Backus wrote:
Taking the address of a local variable is forbidden in @safe
code. Even though str is a ref variable that points to a
heap-allocated string, it is still considered a
On Monday, 10 January 2022 at 01:16:31 UTC, forkit wrote:
On Sunday, 9 January 2022 at 21:56:05 UTC, Salih Dincer wrote:
Try the @trusted and in/out:
...
..
.
thanks for introducing me to the in/out feature of D :-)
I'll certainly look into that feature more.
But my question still remains:
On Thursday, 6 January 2022 at 16:12:10 UTC, HuskyNator wrote:
I can't figure out why this code works:
```d
union A {
int* b;
float c;
}
int fun(A a) @safe {
return *(()=>a.b)();
// return *a.b; //Complains about pointer type overlap
}
```
I tried to find out
On Wednesday, 5 January 2022 at 04:35:12 UTC, Tejas wrote:
```d
import std.stdio:writeln;
ref int func(return ref int a){
a = 6; // modifies a as expected
return a;
}
void main(){
int a = 5;
auto c = func(a); // I expected c to alias a here
c = 10; // Expected to modify a as
On Tuesday, 4 January 2022 at 17:01:41 UTC, Amit wrote:
Hi!
I wrote a text parser that takes a File argument and parses
that file's contents. Now I would like to write a unit-test for
that parser. I need a File (or a general IO interface) that
reads from an in-memory buffer, similar to
On Sunday, 2 January 2022 at 09:15:32 UTC, eugene wrote:
```
p1.d(9): Error: cannot cast expression `until(b[], '\x0a',
Flag.yes)` of type `Until!("a == b", ubyte[], char)` to `char[]`
```
Here's a working version:
```d
import std.stdio;
import std.string;
import std.algorithm : until,
On Thursday, 30 December 2021 at 02:04:30 UTC, Ali Çehreli wrote:
On 12/29/21 5:14 PM, Paul Backus wrote:
Therefore, when you write your own copy constructors, you
should always use `inout` if possible, so that
compiler-generated copy constructors will be able to copy
instances of your
On Thursday, 30 December 2021 at 01:04:10 UTC, Ali Çehreli wrote:
2) Unlike the examples there, I think the parameter should most
usefully be defined as 'const' unless there is a special reason:
struct S {
// const(S) instead of S:
this(ref const(S) that) {
}
}
Do you agree?
When the
On Tuesday, 28 December 2021 at 00:42:18 UTC, data pulverizer
wrote:
On Tuesday, 28 December 2021 at 00:32:03 UTC, Paul Backus wrote:
In this case, the simplest solution is to have your code
generator accept a string as its input, rather than a type.
For example:
```d
enum instantiate(string
On Tuesday, 28 December 2021 at 00:13:13 UTC, data pulverizer
wrote:
The types I'm generating are a template type I've constructed
for R's SEXP, so that my wrapped numeric vector (struct) type
is denoted `RVector!(REALSXP)`. But `alias REALSXP =
SEXPTYPE.REALSXP` where `SEXPTYPE` is an `enum`.
On Friday, 24 December 2021 at 15:46:17 UTC, Salih Dincer wrote:
On Friday, 24 December 2021 at 14:29:29 UTC, Paul Backus wrote:
`protected` in D means "this symbol can only be accessed from
(a) the module where it's defined, and (b) classes that
inherit from the class where it's defined."
On Friday, 24 December 2021 at 12:10:32 UTC, Salih Dincer wrote:
What is the difference between protected and private? Also how
can a function outside of the class access it?
`private` in D means "this symbol can only be accessed from the
module where it's defined."
`protected` in D
On Wednesday, 22 December 2021 at 15:20:15 UTC, Christian Köstlin
wrote:
https://github.com/rui314/mold
Kind regards,
Christian
This was recently discussed in the "General" forum:
https://forum.dlang.org/thread/fiyfgqykhdmglqypx...@forum.dlang.org
On Saturday, 18 December 2021 at 19:48:00 UTC, D Lark wrote:
Can someone please tell me if this is expected behaviour and
what the reasoning is behind this choice?
Looks like a bug. I've filed a report on the D issue tracker:
https://issues.dlang.org/show_bug.cgi?id=22608
On Sunday, 12 December 2021 at 13:42:08 UTC, Martin B wrote:
On Sunday, 12 December 2021 at 13:21:06 UTC, Adam D Ruppe wrote:
On Sunday, 12 December 2021 at 13:11:58 UTC, Martin B wrote:
Just add a forwarding overload:
Hi Adam,
i am wondering if there is another possibility without having
to
On Saturday, 11 December 2021 at 20:22:13 UTC, frame wrote:
```d
// iteration works, but scope behind does nothing
for({int i=0; j=0;} i<10; ++i, {++i; ++j;} ){}
// endless loop
for({int i=0; j=0;} i<10; {++i; ++j;} ){}
```
Not sure if bug or feature but it is inconsistent for me and
thus a
On Thursday, 2 December 2021 at 23:29:17 UTC, Chris Katko wrote:
Is there a D std.library accessible version of POSIX
sched_yield:
https://man7.org/linux/man-pages/man2/sched_yield.2.html
D bindings for POSIX headers are provided by modules in the
package `core.sys.posix`. So, for
On Thursday, 2 December 2021 at 11:35:53 UTC, D Lark wrote:
I am a newcomer to D and I am looking for equivalent
functionality in phobos (so far I have not found).
The function you are looking for is [`std.range.tee`][1].
It was added to Phobos in 2014 by [pull request #1965][2],
On Thursday, 25 November 2021 at 07:26:48 UTC, sclytrack wrote:
int * pureFunction()
1) the pointer needs to be the same.
2) the value that the pointer points to needs to be the same. I
call this the "value
of interest" with relation to pure. The pointer doesn't matter.
3) both the pointer
On Friday, 19 November 2021 at 14:05:40 UTC, rempas wrote:
So, when I assign the value of the variable "name" in the
"other_name", first it will call the copy constructor, then it
will call the assignment constructor and then it will call the
copy constructor again. Why is this happening? I
On Thursday, 18 November 2021 at 13:51:42 UTC, Martin
Tschierschke wrote:
Hello, if you take the example from the home page, with the
additional last line:
```d
struct Point
{
private double[2] p;
// Forward all undefined symbols to p
alias p this;
double dot(Point rhs)
{
On Wednesday, 17 November 2021 at 14:51:58 UTC, Abby wrote:
Hello I would like to create validation mixin or mixin template
which would return on error.
Something like this:
```
mixin template Validate(a, b)
{
if(a > b)
{
writeln("invalid input");
return false;
}
}
On Tuesday, 16 November 2021 at 18:12:34 UTC, chopchop wrote:
Hi,
I have a class Ground which defines some playground constants
(at least constant to the class):
```
class Ground
{
immutable WALL = -2;
immutable playgroundWidth = 77;
immutable playgroundHeight
On Thursday, 4 November 2021 at 18:21:06 UTC, Andrey Zherikov
wrote:
On Thursday, 4 November 2021 at 13:03:54 UTC, Paul Backus wrote:
Have the lambda return by reference:
```d
auto get()
{
return idx.map!(ref (i) => a[i]);
}
```
Making this example a bit complex: I want `get` to return
On Thursday, 4 November 2021 at 11:26:30 UTC, Andrey Zherikov
wrote:
I have the following code example:
```d
struct A{}
A[5] a;
ulong[] idx = [1,3,4];
auto get()
{
return idx.map!(_ => a[_]);
}
foreach(i; 0 .. a.length)
write([i], " ");
writeln;
foreach(ref b; get())
write(, "
On Monday, 1 November 2021 at 16:00:05 UTC, Arsium wrote:
Hello,
Currently, I'm working to implement myself WinAPI functions.
However, I could not find anything matching with : __cpuid
like : https://gist.github.com/boxmein/7d8e5fae7febafc5851e
Any idea ?
Not sure if it's exactly the
On Sunday, 31 October 2021 at 16:54:35 UTC, pascal111 wrote:
Hi! I'm C learner and found the high similarity between C and
D, and was converting C code into D but couldn't get the
equivalent of this C statement "srand(time(NULL));".
Since D gives you access to the C standard library, you can
On Friday, 29 October 2021 at 17:40:38 UTC, Andrey Zherikov wrote:
I want to have a pointer to a value in an associative array.
Does AA guarantee that the value will remain at the same
address all the time unless I remove the corresponding key? I
couldn't find any guarantees similar to C++
On Thursday, 28 October 2021 at 09:02:52 UTC, JG wrote:
I am heavily using SumType (which I like very much). The
problem I am having is that is seems to be causing slow compile
times (as can be observed by profiling during the compile). The
problem seems to be with match (which is extremely
On Monday, 18 October 2021 at 15:04:11 UTC, Don Allen wrote:
Section 12.17 of the Language Reference does not indicate any
circumstance in which a dynamic array, which the literal is, is
implicitly coerced to a pointer.
This is a special case for string literals, covered in [section
On Monday, 18 October 2021 at 03:42:35 UTC, Paul Backus wrote:
My guess is that you got into this situation by trying to
follow the example in the spec's section on ["Slice Assignment
Operator Overloading"][2]. Unfortunately, that example is
incorrect.
[2]:
On Sunday, 17 October 2021 at 22:52:27 UTC, Elmar wrote:
Hello Dear community.
I'd like to overload `opIndexAssign` for a struct which wraps
around a generic array (so that it can't support `opIndex` due
to unknown return type).
Broken down as much as possible this is the code:
```
import
On Sunday, 17 October 2021 at 02:42:54 UTC, Tejas wrote:
Doesn't solve the compile-time only problem though :(
The only solution I can think of is something with `variant`s,
but it'll be messy.
Well, the fundamental issue is that in a language like D that
compiles to machine code, variable
On Saturday, 16 October 2021 at 23:07:22 UTC, DLearner wrote:
```d
void main() {
import std.stdio;
int fooVar = 4;
string strVar;
strVar = "fooVar";
writeln(typeof(mixin(strVar)));
writeln(mixin(strVar));
}
```
Failed with 2x "Error: variable `strVar` cannot be read at
On Friday, 15 October 2021 at 20:33:33 UTC, JN wrote:
Is there some nice way of achieving something like this C99
code in D?
```c
#include
typedef struct {
int x, y;
} inputs_t;
void foo(inputs_t* optional_inputs)
{
if (!optional_inputs) {
printf("0 0\n");
} else {
On Thursday, 14 October 2021 at 16:53:17 UTC, Kostiantyn Tokar
wrote:
Take a look at `Tuple`
[constructor](https://github.com/dlang/phobos/blob/4130a1176cdb6111b0c26c7c53702e10011ff067/std/typecons.d#L672).
```d
this(Types values)
{
field[] = values[];
}
```
Actual fields are constructed
On Tuesday, 12 October 2021 at 21:42:45 UTC, IGotD- wrote:
On Tuesday, 12 October 2021 at 09:20:42 UTC, Elronnd wrote:
There is no good way.
Can't it be done using function overloading?
Function overloading lets you distinguish between arguments with
different types, but strings in
On Tuesday, 12 October 2021 at 15:55:40 UTC, Johann Lermer wrote:
Thanks, understood. But isn't this a deficiency in the library
that should be fixed?
You mean the part about how `Object.toHash` doesn't work with
`const`? Yes, it is a deficiency in the library. The problem is,
it cannot be
On Tuesday, 12 October 2021 at 09:30:57 UTC, Johann Lermer wrote:
Hi all,
I have a problem with Tuples and struct templates that contain
an alias this:
```d
import std;
struct Element(T)
{
T payload;
alias payload this;
this (T p)
{
payload =
On Monday, 11 October 2021 at 15:57:00 UTC, apz28 wrote:
The subject is why the call is not allowed (format is not
mention in question). Below sample is a bit more clear
[...]
ref Writer outFail(Writer, Char)(return ref Writer sink)
if (isOutputRange!(Writer, Char) &&
On Monday, 11 October 2021 at 00:19:44 UTC, apz28 wrote:
/* Getting this error
onlineapp.d(34): Error: none of the overloads of `toString` are
callable using argument types `(Buffer)`, candidates are:
onlineapp.d(19):`onlineapp.Foo.toString()`
onlineapp.d(26):
On Saturday, 9 October 2021 at 21:26:52 UTC, Chris Piker wrote:
Unfortunately importing `core.time` brings in a seconds
function, which due to UFC is confused with a structure member
of the same name.
How can I explicitly tell the compiler that I'm referring to:
```d
thing.seconds # The
On Monday, 4 October 2021 at 11:38:04 UTC, bauss wrote:
Actually it is covered by the spec.
See:
https://dlang.org/spec/expression.html#mixin_expressions
It clearly says:
```
Each AssignExpression in the ArgumentList is evaluated at
compile time
```
Which means that Br cannot be used in
On Sunday, 3 October 2021 at 03:34:19 UTC, surlymoor wrote:
Lord, I'm careless. Thanks.
So the difference between a `mixin template` and a regular one
is that the former may only be used with a `mixin` statement?
Yes, exactly.
On Sunday, 3 October 2021 at 02:52:20 UTC, surlymoor wrote:
This compiles and works. I checked the spec, and I don't see
anything; probably missed it, however; mentioning the fact that
regular templates may be used with `mixin`. Is this expected?
Yes, this is intentional and expected. From
On Monday, 20 September 2021 at 20:02:24 UTC, NonNull wrote:
How do I write the type of a function so as to alias it, and
use that in an extern(C) declaration?
For example, how do I write the type of an external function
int main2(int argc, char** argv) {
//
}
You can create an alias to
On Monday, 20 September 2021 at 11:21:28 UTC, surlymoor wrote:
The error in question...
```
Error: variable
`std.typecons.ReplaceTypeUnless!(isSumTypeInstance, This,
SumType!(Foo!(bar)), Foo!(bar)).F!(bar).replaceTemplateArgs`
type `void` is inferred from initializer `bar()`, and variables
On Sunday, 19 September 2021 at 12:00:22 UTC, Hipreme wrote:
Basically: I have a main program which would contain a lot of
code. I have a secondary program which I want to call code from
the main program, but it will be compiled as a DLL to the main
program call a single entry point from that
On Wednesday, 15 September 2021 at 20:32:12 UTC, eXodiquas wrote:
```d
[1,0,3,4,0,5]
.fold!((a, e) => e != 0 ? a[0] ~ e : a[1] ~ e)(cast(int[][])
[[],[]])
.flatten
.writeln
```
This should sort all non 0s into the `a[0]` array and all 0s
into the `a[1]` array. But it won't work because the
On Monday, 13 September 2021 at 14:42:42 UTC, jfondren wrote:
On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote:
- condition al expression ` cond ? exp : exp `
And many other boolean operators, unary !, binary && and ||
https://dlang.org/spec/operatoroverloading.html lists all the
On Monday, 13 September 2021 at 00:53:06 UTC, leikang wrote:
I want to contribute to the development of the dlang language,
but I feel that I am insufficient, so I want to ask the big
guys, can I participate in the development of the Dlang
language after learning the principles of compilation?
On Tuesday, 7 September 2021 at 05:00:50 UTC, Chris Piker wrote:
On Tuesday, 7 September 2021 at 04:40:25 UTC, jfondren wrote:
typeof(parseXML!simpleXML("")) xml;
Hey, I like this trick!
I was wondering what to use for the const(char)[] variable in
the typeof statement. It's
On Monday, 6 September 2021 at 13:24:56 UTC, Basile B. wrote:
It's because the clients of an allocator should rather
statically check for specific traits of an allocator, there are
too many possible permutations of capabilities possible, not
all can allocate and deallocate, not all can
On Sunday, 5 September 2021 at 19:43:20 UTC, james.p.leblanc
wrote:
Dear D-ers,
I have constructed a custom array type that works, but is
missing
correct functioning on some operator overloads.
[...]
```d
import std.stdio;
import myarray_mod;
```
Please post the source code for
On Friday, 3 September 2021 at 23:39:44 UTC, Per Nordlöw wrote:
When is a phobos unittest supposed to be qualified with version
`(StdUnittest)`?
Almost never.
`version (StdUnittest)` should be used in Phobos wherever you
would normally use a `version (unittest)` block. It is not for
the
On Saturday, 4 September 2021 at 00:09:37 UTC, H. S. Teoh wrote:
This is related to the bogonity of the current behaviour of
-unittest, which compiles *all* unittests of *all* imported
modules, even when you're compiling user code that has no
interest in Phobos unittests.
Well, no; it
On Tuesday, 31 August 2021 at 14:09:01 UTC, Steven Schveighoffer
wrote:
Are you sure this is the problem? `PdfSurface` is not a valid
identifier here except for the class. In order to access the
package, you need to use `cairo.PdfSurface`.
Must've changed since you last checked:
```d
//
On Tuesday, 31 August 2021 at 12:57:33 UTC, frame wrote:
No, it has one, eg:
```d
module cairo.PdfSurface;
```
but the filename is PdfSurface.d and class name also :\
You can use a selective import:
```d
import cairo.PdfSurface: PdfSurface;
```
On Sunday, 29 August 2021 at 16:21:40 UTC, jfondren wrote:
... after Phobos is patched.
```
error: undefined identifier ‘Lhs’, did you mean alias ‘Rhs’?
```
Shows how much anyone actually uses this code, I guess--the bug
was introduced [in 2017][1], and as far as I can tell has never
even
On Sunday, 29 August 2021 at 15:42:18 UTC, Ali Çehreli wrote:
Depending on the situation, you may want to use std.conv.to,
which does a value range check and throws an exception to
prevent an error:
byte foo(byte a, byte b) {
import std.conv : to;
return (a + b).to!byte;
}
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote:
Please confirm that mixins of format:
```
string mxn1(string VarName) {
...
}
```
Invoked like:
```
mixin(mxn1("Var1"));
```
Have a wider scope than mixins like:
```
string mxn2(string VarName)() {
...
}
```
Invoked like:
```
1 - 100 of 661 matches
Mail list logo