On Monday, 12 October 2020 at 10:24:44 UTC, FreeSlave wrote:
Let's say I use Flag type named 'myflagname' in API like this:
import std.typecons;
void func(Flag!"myflagname" flag)
{
//...
}
void main()
{
func(Yes.myflagname);
}
Later I realize that 'myflagname' is a bad name and I want to
On Wednesday, 23 September 2020 at 19:27:13 UTC, Steven
Schveighoffer wrote:
This is a bug in the language.
🤯😆
On Wednesday, 23 September 2020 at 18:38:53 UTC, 60rntogo wrote:
There are really two questions here, one that I intended to ask
and one that came out while I was trying to figure out the
answer. Consider this simple code:
[...]
Yeah, you can make a property setter:
private void x(int newVa
On Saturday, 18 July 2020 at 09:10:04 UTC, Mr. Backup wrote:
Hello,
I wanted to create simple web service to start learning more
about D lang and compare with another languages. I have used
"dub init -t vibe.d" to create basic example:
[...]
Think it's just Vibe.d:
I had a similar issue:
On Monday, 27 April 2020 at 06:23:08 UTC, Andre Pany wrote:
On Sunday, 26 April 2020 at 22:07:56 UTC, aliak wrote:
On Saturday, 25 April 2020 at 18:52:45 UTC, Andre Pany wrote:
[...]
I'm sorry I didn't follow.
You mean like:
"dub test"
??
I dont pass anything to the -b or -c flag if that'
On Saturday, 25 April 2020 at 18:52:45 UTC, Andre Pany wrote:
How do you call dub test causing the issue? Maybe there is a
difference in the configuration/build type.
I'm sorry I didn't follow.
You mean like:
"dub test"
??
I dont pass anything to the -b or -c flag if that's what you mean?
On Saturday, 25 April 2020 at 19:00:55 UTC, Anonymouse wrote:
On Saturday, 25 April 2020 at 09:38:59 UTC, aliak wrote:
Then I run this dub dustmite command:
dub dustmite -b unittest ../dubdust --compiler-regex="never
matches"
I have had zero luck with dustmite via dub. I would honestly
reco
Trying to get dub dustmite to work, but I keep getting "initial
test fails"
This is the error from a vanilla dub test:
```
result ~wip: building configuration "result-test-unittest"...
inout(SumType!(int, FailureContainer))
../../.dub/packages/sumtype-0.9.4/sumtype/src/sumtype.d(1322,4):
Error
On Wednesday, 22 April 2020 at 10:32:48 UTC, Russel Winder wrote:
Now I discover Python, Rust, and Go have far nicer abstractions
for writing Internet code than D does. Does D really not have a
TcpListener abstraction?
It really doesn't :(
And D has so much potential as server tech with the
On Tuesday, 21 April 2020 at 16:30:15 UTC, Russel Winder wrote:
On Mon, 2020-04-20 at 20:19 +, aliak via
Digitalmars-d-learn wrote:
[…]
[0]: https://github.com/aliak00/optional
Rust has Option and Result, and most languages are rapidly
introducing at least Option if not Result – and
On Friday, 17 April 2020 at 16:56:57 UTC, Russel Winder wrote:
Hi,
Thinking of trying to do the next project in D rather than
Rust, but…
Rust has built in unit testing on a module basis. D has this so
no problem.
Rust allows for integration tests in the tests directory of a
project. These
On Tuesday, 31 March 2020 at 15:23:48 UTC, Anonymouse wrote:
I have a library package that I split up into subpackages, but
I'm having to do mental gymnastics to make it only compile the
files I want.
The problem is that even if you specify some `sourceFiles`, it
will build everything under t
On Saturday, 14 March 2020 at 19:04:28 UTC, 12345swordy wrote:
I.E.
switch (object)
case Type1 t1:
case Type2 t2:
case Type3 t3:
You can use the sumtype package
(https://code.dlang.org/packages/sumtype):
alias T = SumType!(Type1, Type2, Type3);
T(object).match!(
(Type1 t1)
On Wednesday, 4 March 2020 at 12:03:48 UTC, Gregor Mückl wrote:
Hi!
I've just created a situation in my code that is summarized by
the following example. I don't know how to solve it with @safe
code.
A third party library provides a struct that is not copyable:
// provided by third party
st
On Monday, 2 March 2020 at 23:27:22 UTC, Steven Schveighoffer
wrote:
What I think is happening is that it determines nobody is using
the result, and the function is pure, so it doesn't bother
calling that function (probably not even the lambda, and then
probably removes the loop completely).
On Monday, 2 March 2020 at 21:33:37 UTC, Steven Schveighoffer
wrote:
On 3/2/20 3:52 PM, aliak wrote:
On Monday, 2 March 2020 at 15:47:26 UTC, Steven Schveighoffer
wrote:
On 3/2/20 6:52 AM, Andrea Fontana wrote:
On Saturday, 29 February 2020 at 20:11:24 UTC, Steven
Schveighoffer wrote:
1. in is
On Monday, 2 March 2020 at 15:47:26 UTC, Steven Schveighoffer
wrote:
On 3/2/20 6:52 AM, Andrea Fontana wrote:
On Saturday, 29 February 2020 at 20:11:24 UTC, Steven
Schveighoffer wrote:
1. in is supposed to be O(lg(n)) or better. Generic code may
depend on this property. Searching an array is O(
On Monday, 2 March 2020 at 15:50:08 UTC, Steven Schveighoffer
wrote:
On 3/2/20 6:39 AM, JN wrote:
On Saturday, 29 February 2020 at 21:56:51 UTC, Ali Çehreli
wrote:
Because you mentioned canFind, I think you want the semantics
to be "is there an element with this value." If so, it would
be conf
On Thursday, 20 February 2020 at 23:21:23 UTC, MoonlightSentinel
wrote:
On Thursday, 20 February 2020 at 22:31:16 UTC, aliak wrote:
Is this suppose to give a deprecation error message?
deprecated("a")
alias A(T) = B!T;
template B(T) {
alias B = T;
}
void main() {
A!int a; // should th
Is this suppose to give a deprecation error message?
deprecated("a")
alias A(T) = B!T;
template B(T) {
alias B = T;
}
void main() {
A!int a; // should this cause a message "a" ?
}
??
Or am I using it wrong maybe?
On Thursday, 13 February 2020 at 15:38:37 UTC, Steven
Schveighoffer wrote:
On 2/13/20 9:47 AM, aliak wrote:
[...]
Not sure about your error, but here is a working version (don't
use mixins, use __traits(getMember)):
import std.meta;
template ListOfStructs(alias mod)
{
enum isStruct(stri
Hi,
I'm trying to get a typed list of structs in my current module
that matches certain criteria. Something like:
module mod;
struct X {}
struct Y {}
alias allTypes = ListOfTypes!mod;
But I'm having a bit of trouble. I have this so far:
template ListOfTypes(alias T) {
import std.meta;
On Saturday, 30 November 2019 at 18:15:47 UTC, Treebeard wrote:
Hoom, hum, I met a dark forest of complains from the compilers
here.
[...]
/me thinks it's a bug
Pushed a pr. Let's see.
https://github.com/dlang/phobos/pull/7298
On Saturday, 30 November 2019 at 13:45:00 UTC, kerdemdemir wrote:
I have simplified my problem which can be seen below.
import std.stdio;
import vibe.core.core;
import vibe.core.concurrency;
import vibe.data.json;
void main()
{
int[] list;
bool ListManipulator(ref int[] list)
{
On Sunday, 24 November 2019 at 17:04:49 UTC, Steven Schveighoffer
wrote:
On 11/24/19 10:44 AM, aliak wrote:
[...]
Hm.. are you sure that ctrl-c isn't also sending the signal to
your child process? I thought it did.
-Steve
Yesh, you're right. That extra kill is unnecessary and was
actuall
On Sunday, 24 November 2019 at 16:05:14 UTC, mipri wrote:
On Sunday, 24 November 2019 at 15:44:00 UTC, aliak wrote:
[...]
This might be useful:
---
#! /usr/bin/env rdmd
import std;
import core.stdc.signal;
[...]
waitpid, of course! Thanks agin :)
I'm writing some command line tooling stuff, and one of the
command spins up a docker compose file (which in short, spins up
some services and aggregates the output of each service to
stdout).
When a user presses ctrl+c, i would like to pass on the ctrl+c to
the spawned process and wait till
On Saturday, 23 November 2019 at 12:19:27 UTC, Steven
Schveighoffer wrote:
On 11/23/19 4:54 AM, aliak wrote:
Is there a way to go about killing a process after spawning it
on a SIGINT?
I can't do this for e.g. because kill is not @nogc.
Pid currentSpawnedPid;
extern(C) void killCurrentPidHand
On Saturday, 23 November 2019 at 10:09:51 UTC, mipri wrote:
On Saturday, 23 November 2019 at 09:54:48 UTC, aliak wrote:
Is there a way to go about killing a process after spawning it
on a SIGINT?
I can't do this for e.g. because kill is not @nogc.
Well, this works:
import std;
import core.s
Is there a way to go about killing a process after spawning it on
a SIGINT?
I can't do this for e.g. because kill is not @nogc.
Pid currentSpawnedPid;
extern(C) void killCurrentPidHandler(int sig) nothrow @nogc
@system {
kill(currentSpawnedPid, sig);
}
int main() {
currentSpawnedPid = sp
On Friday, 6 September 2019 at 10:37:16 UTC, aliak wrote:
Are there any library APIs that allow this:
I just put this together. Any holes other the AA related ones?
Will it work with classes?
auto dupDeep(T)(ref T thing) {
import std.range: ElementType;
import std.traits: hasAliasing,
Are there any library APIs that allow this:
struct S {
int[] arr;
}
void main() {
const a = S([1,2,3]);
S b = a.copy; // deep dup/copy
}
I'd also like to avoid implementing a copy constructor for each
type.
On Saturday, 17 August 2019 at 16:43:51 UTC, Paul Backus wrote:
On Friday, 16 August 2019 at 08:07:28 UTC, aliak wrote:
Hi, I'm trying to fix a use-case where you have a wrapper
template type (it's an optional) and the wrapping type has
@disable this(this). And having this scenario work:
stru
On Friday, 16 August 2019 at 14:29:26 UTC, Paul Backus wrote:
On Friday, 16 August 2019 at 08:07:28 UTC, aliak wrote:
[...]
Even simpler:
void opAssign(auto ref Optional!T rhs) {
import core.lifetime: forward;
this._value = forward!rhs;
}
That doesn't work with private members unfor
Hi, I'm trying to fix a use-case where you have a wrapper
template type (it's an optional) and the wrapping type has
@disable this(this). And having this scenario work:
struct S {
@disable this(this);
}
Optional!S fun() {...}
Optional!S a;
a = fun.move;
Now that won't work because of the di
On Saturday, 10 August 2019 at 17:45:43 UTC, Prateek Nayak wrote:
A nested function can be passed to another function evident
from this example: https://run.dlang.io/is/6waRkB
However if the nested function is a template function, it
raises an error
https://run.dlang.io/is/PQhkwl
The error be
Can someone help me understand the details around why this fails?
import std;
struct W(T) {
T value;
auto hook(handlers...)() {
return handlers[0](value);
}
}
template f(handlers...) {
auto ref f(T)(auto ref T value) {
return value.hook!handlers;
}
}
@nogc v
On Friday, 26 July 2019 at 16:20:10 UTC, aliak wrote:
Can someone help me understand the details around why this
fails?
import std;
struct W(T) {
T value;
auto hook(handlers...)() {
return handlers[0](value);
}
}
template f(handlers...) {
auto ref f(T)(auto ref T value
On Friday, 26 July 2019 at 16:21:52 UTC, aliak wrote:
On Friday, 26 July 2019 at 16:20:10 UTC, aliak wrote:
Can someone help me understand the details around why this
fails?
import std;
struct W(T) {
T value;
auto hook(handlers...)() {
return handlers[0](value);
}
}
templ
On Thursday, 25 July 2019 at 21:23:33 UTC, Paul Backus wrote:
On Thursday, 25 July 2019 at 20:38:59 UTC, aliak wrote:
On Thursday, 25 July 2019 at 19:35:36 UTC, aliak wrote:
Basically, can template W be made to handle an S that can't
be copied?
import std;
static struct S {
int i;
@d
On Thursday, 25 July 2019 at 19:35:36 UTC, aliak wrote:
Basically, can template W be made to handle an S that can't be
copied?
import std;
static struct S {
int i;
@disable this(this);
this(int i) { this.i = i; }
}
struct W(T) {
T value;
this(T value) {
this.value
Basically, can template W be made to handle an S that can't be
copied?
import std;
static struct S {
int i;
@disable this(this);
this(int i) { this.i = i; }
}
struct W(T) {
T value;
this(T value) {
this.value = value;
}
}
auto wrap(T)(T value) {
return W!T(
On Wednesday, 24 July 2019 at 16:23:48 UTC, Paul Backus wrote:
On Wednesday, 24 July 2019 at 12:54:51 UTC, aliak wrote:
[...]
It should go on the constructor's parameter; i.e.,
this(auto return ref T value) { /* ... */ }
Under the hood, a constructor actually returns the constructed
value b
Trying to get dip1000 flag in use. I have this error:
Error: returning Optional(null, false).this(value) escapes a
reference to parameter value, perhaps annotate with return
in this function:
public auto some(T)(auto ref T value) {
return Optional!T(value); // <-- error on this line
}
An
On Tuesday, 23 July 2019 at 00:36:49 UTC, Exil wrote:
auto ref get(T)(W!T value) {
return value.front;
}
You're returning a reference to a temporary that gets deleted
at the end of the function's scope. The "auto ref" here will be
a "ref".
. oh ... shit you're right.
Ok so this
Hi,
so I had this weird bug that was driving me crazy and only
segfaulted with ldc in release build - (I'm using ldc 1.16.0).
This is the code that segfaults. All parts seem to be necessary
for it to happen, or at least I think so. I've gone in circles
minimizing so I've probably missed some
On Wednesday, 17 July 2019 at 15:52:39 UTC, Newbie2019 wrote:
when build my project with -betterC, it throw this error:
Error: TypeInfo cannot be used with -betterC
There is no location information about it, how can I find what
code cause this ?
You usually get that *extrememly* unhelpful e
On Monday, 8 July 2019 at 23:01:49 UTC, ag0aep6g wrote:
On 08.07.19 23:55, aliak wrote:
[...]
`source.front` is a temporary `Grapheme` and you're calling
`opSlice` on it. The documentation for `Grapheme.opSlice`
warns: "Invalidates when this Grapheme leaves the scope,
attempts to use it the
Problem 1:
I'm trying to get a string to behave as a .byGrapheme range by
default, but I can't figure out Grapheme. I'm trying to replicate
this behavior:
foreach (g; "hello".byGrapheme) {
write(g[]);
}
In a custom type:
struct ustring {
string data;
this(string data) {
On Thursday, 4 July 2019 at 15:22:08 UTC, Marco de Wild wrote:
On Thursday, 4 July 2019 at 15:10:05 UTC, aliak wrote:
[...]
I don't know if it will solve your whole problem, but have you
tried __traits(isSame, W0.fun, fun)?
Reduced example:
struct Foo(alias fun){
alias bar = fun;
}
vo
Any ideas on how to be able to do something like this?
struct S(alias _fun) {
alias Fun = _fun;
}
void algorithm(alias f, T)(T s) {
static if (&f == &T.Fun) {
// trivial return
} else {
// must perform work, then return
}
}
Can you use function addresses in some way? I've seen t
On Friday, 21 June 2019 at 09:01:17 UTC, lili wrote:
Hi Guys:
What is range.iota function full name
That is the full name. Or what do you mean?
Found on the internet somewhere:
"The function is named after the integer function ⍳ from the
programming language APL."
On Tuesday, 18 June 2019 at 01:15:54 UTC, Samir wrote:
On Monday, 17 June 2019 at 03:46:11 UTC, Norm wrote:
On Monday, 17 June 2019 at 00:22:23 UTC, Samir wrote:
Any suggestions on how to rectify?
You could change the IF to
`if(line.length > 0 && line[0] == '>')`
Thanks, Norm. That seem
On Monday, 17 June 2019 at 18:25:24 UTC, Robert M. Münch wrote:
On 2019-06-16 15:14:37 +, rikki cattermole said:
observerObject is an eponymous template.
What this means (in essence) is the symbol inside the template
block == template block.
Hmm... ok. Is there any reason to have these
On Monday, 17 June 2019 at 00:22:23 UTC, Samir wrote:
Also, if I run the program below with the same file, I don't
get any range violation errors:
Ya, writeln will not access individual elements of a range if
there aren't any. So no violations occur.
HOWEVER, the output is interesting. Th
On Sunday, 16 June 2019 at 23:44:49 UTC, Samir wrote:
On Sunday, 16 June 2019 at 23:03:04 UTC, aliak wrote:
stripping the last line could result in an empty line if it
just has strippable characters?
The last line of the file is just text but without a newline
(\n) character or any other whi
On Sunday, 16 June 2019 at 22:47:14 UTC, Samir wrote:
I am trying to read from a text file using the following code:
import std.stdio;
import std.string;
void main() {
File file = File("test.txt");
string line;
while (!file.eof()) {
line = strip(file.readln());
if (
On Friday, 24 May 2019 at 12:03:08 UTC, Simen Kjærås wrote:
On Friday, 24 May 2019 at 11:40:20 UTC, aliak wrote:
It's ref so that you can do this for e.g.
class C { int i; }
auto a = notNull!C;
a.i = 3;
That's a valid concern for a struct, but classes are already
reference types, so you're o
On Friday, 24 May 2019 at 10:40:01 UTC, Simen Kjærås wrote:
On Friday, 24 May 2019 at 10:16:50 UTC, aliak wrote:
Basically, I want this to fail:
auto notNull(T, Args...)(Args args) {
return NotNull!T(new T(args));
}
struct NotNull(T) {
private T _value;
@property ref inout(T) value() i
Basically, I want this to fail:
auto notNull(T, Args...)(Args args) {
return NotNull!T(new T(args));
}
struct NotNull(T) {
private T _value;
@property ref inout(T) value() inout { return this._value; }
alias value this;
//disable opAssign to null as well
}
class C {}
void func(ref C
On Monday, 6 May 2019 at 14:48:56 UTC, faissaloo wrote:
I've been having some memory issues (referenced objects turning
to nulls for no apparent reason) and I was wondering if I've
misunderstood how allocation works when instantiating a struct
that uses alias this:
import std.stdio;
On Monday, 22 April 2019 at 08:02:06 UTC, Arun Chandrasekaran
wrote:
What am I doing wrong here?
struct A
{
union B
{
int bb;
}
B b;
alias aa = B.bb;
}
void main()
{
A a = A();
// a.b.bb = 4; // works
a.aa = 4; // fails
}
https://run.dlang.io/is/kXaVy2
On Sunday, 7 April 2019 at 04:58:13 UTC, Alex wrote:
Is there any way to get sequences of sequences?
Using RT, I have to use strings
[[`string`, `0`], ...]
when it would be much better to use
[[string, 0], ...]
Ideally it wouldn't add so much overhead that it defeats the
purpose.
https://
On Monday, 25 March 2019 at 09:27:03 UTC, Victor Porton wrote:
///
template sychronizedMemoize(alias fun) {
void sychronizedMemoize() { }
}
void f() { }
void main()
{
synchronizedMemoize!f();
}
///
/tmp/temp_7F3C101460D0.d(9,5): Error: template instance
`synchronizedMemoize!f` templat
On Sunday, 17 March 2019 at 20:23:44 UTC, Paul Backus wrote:
On Sunday, 17 March 2019 at 10:49:03 UTC, aliak wrote:
[...]
For some reason, when you call `make("hello")`, the template
argument T is being inferred as char[] instead of string. (You
can see this by putting `pragma(msg, T)` in th
On Sunday, 17 March 2019 at 17:22:13 UTC, Kagamin wrote:
struct S(T) {
T value;
bool opEquals(U:S!V,V)(in U r) const
{ return value==r.value; }
}
Hmm, that actually works for opEquals. But now you just hit the
same problem with some other construct, unfortunately:
auto x = [make(
On Saturday, 16 March 2019 at 03:49:26 UTC, Paul Backus wrote:
On Friday, 15 March 2019 at 23:57:15 UTC, aliak wrote:
Anyone knows how to make this work?
You need an explicit `inout` on the return value of `make`:
auto ref make(T)(inout auto ref T value) {
return inout(S!T)(value);
}
Ah
This is the set up I have, and I'm not sure how to get the main
function at the bottom to compile. The error in the code below is
that it cannot implicitly convert an inout(C) to a C in the
constructor of S(T).
If you remove the constructor that takes an inout then you get a
"cannot deduce fu
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote:
[...]
Here's a much reduces test case:
struct W(T) {}
struct S {
int* data;
}
template match1(alias handler) {
auto ref match1(T)(inout auto ref W!T w) {
return handler();
}
}
template match2(alias handler) {
aut
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote:
Hi,
I have an error that says "Error: returning `match1(opt)`
escapes a reference to parameter `opt`, perhaps annotate with
`return`".
[...]
Ok, I've found out something else. It only happens when you're
returning a type that has an i
Hi,
I have an error that says "Error: returning `match1(opt)` escapes
a reference to parameter `opt`, perhaps annotate with `return`".
The code is here: https://run.dlang.io/is/ESZDW4 (It's copied at
the end of this post as well)
1) If you remove the inout from line 11. It works.
2) If you
On Sunday, 3 March 2019 at 20:41:36 UTC, Alex wrote:
On Sunday, 3 March 2019 at 20:10:14 UTC, aliak wrote:
Is it possible to initialize static immutable members of a
struct like you could do for a global immutable one?
immutable string a;
struct Test {
static immutable string b;
}
shared st
Is it possible to initialize static immutable members of a struct
like you could do for a global immutable one?
immutable string a;
struct Test {
static immutable string b;
}
shared static this() {
a = "foo";
Test.b = "bar";
}
Error: cannot modify immutable expression b
On Saturday, 2 March 2019 at 02:38:09 UTC, H. S. Teoh wrote:
On Sat, Mar 02, 2019 at 02:16:22AM +, Victor Porton via
Digitalmars-d-learn wrote:
[...]
Keep in mind that sequences produced by AliasSeq are
auto-expanding, meaning the above construct will automatically
flatten into a flat Al
On Sunday, 24 February 2019 at 11:05:31 UTC, Alex wrote:
On Sunday, 24 February 2019 at 10:53:09 UTC, aliak wrote:
[...]
There is a semantic difference between a switch and a final
switch statement, defined here:
https://dlang.org/spec/statement.html#final-switch-statement
By this differenc
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 optiona
On Tuesday, 18 December 2018 at 13:52:29 UTC, Steven
Schveighoffer wrote:
On 12/18/18 6:29 AM, Simen Kjærås wrote:
On Tuesday, 18 December 2018 at 10:14:50 UTC, Per Nordlöw
wrote:
What's the preferred way of creating a temporary @trusted
scope without writing a separate function?
Jonathan's
On Monday, 17 December 2018 at 21:59:59 UTC, JN wrote:
Hey guys,
while working on my game engine project, I encountered a DMD
codegen bug. It occurs only when compiling in release mode,
debug works. Unfortunately I am unable to minimize the code,
since it's quite a bit of code, and changing t
On Thursday, 13 December 2018 at 23:33:39 UTC, Stanislav Blinov
wrote:
On Thursday, 13 December 2018 at 13:17:05 UTC, aliak wrote:
[...]
Hypothetically, yes, e.g. an object that contains references to
itself. However, D operates on the assumption that you don't
have such objects. And even t
On Thursday, 13 December 2018 at 12:08:22 UTC, Boris-Barboris
wrote:
On Thursday, 13 December 2018 at 09:51:42 UTC, aliak wrote:
[...]
You can just move in container constructor:
struct S {
@disable this(this);
this(int i) {}
}
struct Container(T) {
T value;
this(T value) {
On Wednesday, 12 December 2018 at 21:11:38 UTC, Paul Backus wrote:
On Wednesday, 12 December 2018 at 20:05:18 UTC, aliak wrote:
Ie:
struct S {
@disable this();
this(int i) {}
}
struct Container(T) {
T value;
this(auto ref T value) {
this.value = value;
}
}
void mai
Ie:
struct S {
@disable this(this);
this(int i) {}
}
struct Container(T) {
T value;
this(T value) {
this.value = value;
}
}
void main() {
auto a = Container!S(S(3)); // can't do this.
}
I can build a custom constructor for Container that makes this
work:
stat
Ie:
struct S {
@disable this();
this(int i) {}
}
struct Container(T) {
T value;
this(auto ref T value) {
this.value = value;
}
}
void main() {
auto a = Container!S(S(3)); // can't do this.
}
I can build a custom constructor for Container that makes this
work:
On Sunday, 9 December 2018 at 18:36:50 UTC, Dennis wrote:
I'm using Adam's workaround from
https://issues.dlang.org/show_bug.cgi?id=19365, but now I have
endless recursion. Reduced code:
```
mixin template operators() {
S opBinary(string op: "+")(S rhs) {
return rhs;
}
//
On Monday, 10 December 2018 at 11:08:23 UTC, Narxa wrote:
Hello, people!
I would like to have a constant with the value of some
environment variable that is defined at compile time.
In FreePascal, it can be done by defining it in source as:
VALUE_OF_SOMETHING = {$I %SOMETHING%};
And I can c
On Saturday, 8 December 2018 at 14:21:01 UTC, Paul Backus wrote:
On Saturday, 8 December 2018 at 09:57:29 UTC, aliak wrote:
This compiles fine. However, if I change the match template to:
template match(handlers...) {
auto match(alias f)(Holder!f holder) {
return handlers[0](holder)
Hi, I'm wondering about why this happens in a certain situation
and not another. I have the following code:
struct Holder(alias fun) {
alias T = typeof(fun());
T get() { return fun(); }
alias get this;
}
template match(handlers...) {
auto match(T)(T holder) {
return hand
On Saturday, 1 December 2018 at 19:02:54 UTC, H. S. Teoh wrote:
In the above contrived example, Artin's conjecture is implied
by the Riemann hypothesis, so the second if statement would
only run if p is initialized. But there is no way the compiler
is going to be able to deduce this, especial
On Monday, 26 November 2018 at 03:09:03 UTC, Mike Parker wrote:
I mean, can you think of any module in the
Python/Javascript/C# standard library that simply including it
will swell your program to the point it can't compile? I'm not
an omnipotent master programmer, but as a professional, I
can
On Wednesday, 21 November 2018 at 23:27:25 UTC, Alex wrote:
Nice! Didn't know that... But the language is a foreign one for
me.
Nevertheless, from what I saw:
Shouldn't it be
var x: C?
as an optional kind, because otherwise, I can't assign a nil to
the instance, which I can do to a class insta
On Wednesday, 21 November 2018 at 17:46:29 UTC, Alex wrote:
compiled against 4.6.1 Framework.
However, of course, there is a NullReferenceException, if c
happens to be null, when calling baz.
So the difference is not the compiler behavior, but just the
runtime behavior...
How could the com
On Tuesday, 20 November 2018 at 15:29:50 UTC, Kagamin wrote:
On Tuesday, 20 November 2018 at 11:11:43 UTC, aliak wrote:
This only applies to little scripts and unittests maybe.
Not when you're writing any kind of relatively larger
application that involves being run for longer or if there's
m
On Monday, 19 November 2018 at 21:39:22 UTC, Adam D. Ruppe wrote:
On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez
Hermoso wrote:
What's the reasoning for allowing this?
The mistake is immediately obvious when you run the program, so
I just don't see it as a big deal. You lose a m
On Tuesday, 20 November 2018 at 03:24:56 UTC, Neia Neutuladh
wrote:
On Tue, 20 Nov 2018 00:30:44 +, Jordi Gutiérrez Hermoso
wrote:
On Monday, 19 November 2018 at 21:57:11 UTC, Neia Neutuladh
wrote:
Programmers coming from nearly any language other than C++
would find it expected and intui
On Tuesday, 20 November 2018 at 00:30:44 UTC, Jordi Gutiérrez
Hermoso wrote:
On Monday, 19 November 2018 at 21:57:11 UTC, Neia Neutuladh
wrote:
[...]
What do you think about making the syntax slightly more
explicit and warn or possibly error out if you don't do it that
way? Either
Some
On Saturday, 17 November 2018 at 21:56:23 UTC, Neia Neutuladh
wrote:
On Sat, 17 Nov 2018 21:16:13 +, aliak wrote:
Could do. But it's not scalable. I'd have to comment out all
the unittests that call the template function with a T that
allocates inside the @nogc template (if I understood you
On Saturday, 17 November 2018 at 17:48:43 UTC, Neia Neutuladh
wrote:
On Sat, 17 Nov 2018 13:55:24 +, aliak wrote:
You can use "debug blah" to hide inside functions that are
attributed, but when you have an attributed function that
calls a template, attribtues of which are supposed to be
in
On Saturday, 17 November 2018 at 13:46:00 UTC, Nicholas Wilson
wrote:
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote:
On Friday, 16 November 2018 at 13:21:39 UTC, Stanislav Blinov
wrote:
auto assumeNoGC(T)(return scope T t) @trusted { /* ... */ }
Sawweet! Thanks, that made the pri
On Saturday, 17 November 2018 at 13:43:20 UTC, Stanislav Blinov
wrote:
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote:
Sawweet! Thanks, that made the printing possible!
You're welcome ;) Still, try a more recent compiler. This works
fine:
void foo() @nogc {
debug {
On Friday, 16 November 2018 at 13:03:40 UTC, Zoadian wrote:
debug {
import std.stdio;
writeln(args);
}
As mentioned in the original post, that does not work.
1 - 100 of 292 matches
Mail list logo