On Thursday, 13 August 2020 at 07:52:07 UTC, novice3 wrote:
Hello.
I don't use dub.
I use Windows and *.d file association to compile small apps by
dmd with "-i -unittest -g" switches.
Now i update dmd, and found, that apps compiled with
"-unittest" not runs main().
How i can restore old beh
I can use `std.traits.getSymbolsByUDA` to get all the members of
a class that have a particular UDA `getSymbolsByUDA(ValueType,
UDA)`.
But how do I get the values with it?
Is there a more convenient way than `__traits(getMember, value,
getSymbolsByUDA(ValueType, UDA)[0].stringof)`?
I am using a C bindings library
(https://code.dlang.org/packages/xcb-d).
I am following through a tutorial that was written for the C
library directly and just making the minor changes to make it
work with D.
I ran into a problem. The library ends up giving me a struct
pointer.
```
xcb_ge
Is there a way in D to take past arguments as an array? A like a
normal Variadic function. All the arguments should be of the
same type just as an array.
Basically I want to allow a function like this to be called
without square brackets.
void fun(int[] intArray) {
//...
}
void main()
On Tuesday, 10 April 2018 at 23:59:08 UTC, Steven Schveighoffer
wrote:
On 4/9/18 6:56 PM, Jonathan wrote:
On Monday, 9 April 2018 at 22:53:31 UTC, Jonathan wrote:
On Monday, 9 April 2018 at 22:49:07 UTC, Cym13 wrote:
I don't know, but I can't reproduce either with dmd or ldc.
What was your com
On Monday, 9 April 2018 at 22:56:33 UTC, Jonathan wrote:
On Monday, 9 April 2018 at 22:53:31 UTC, Jonathan wrote:
On Monday, 9 April 2018 at 22:49:07 UTC, Cym13 wrote:
I don't know, but I can't reproduce either with dmd or ldc.
What was your compilation line?
dmd -run file.d
I am on Window
On Monday, 9 April 2018 at 22:53:31 UTC, Jonathan wrote:
On Monday, 9 April 2018 at 22:49:07 UTC, Cym13 wrote:
I don't know, but I can't reproduce either with dmd or ldc.
What was your compilation line?
dmd -run file.d
I am on Window 10 btw.
On Monday, 9 April 2018 at 22:49:07 UTC, Cym13 wrote:
I don't know, but I can't reproduce either with dmd or ldc.
What was your compilation line?
dmd -run file.d
I am totally lost on why this is happening.
I stripped the code down to what appears to be the most minimal
code that still causes the problem.
---
import core.sync.mutex;
import core.thread;
import std.stdio;
__gshared Mutex m;//__gshared just for testing (;
void thread1() {
foreach
Everywhere I look the advice is to avoid atomic and just mutex
things.
Why is this `a.atomicStore(b)`(memory order is seq) less safe
than `synchronized{a=b}`? I get that when more operations or
shared values are used it is appropriate to mutex the entire set
of operations but why would I for
On Monday, 26 March 2018 at 17:55:10 UTC, bauss wrote:
On Monday, 26 March 2018 at 16:14:31 UTC, Jonathan wrote:
Can I send data over an std.socket on multiple threads without
manual mutexing?
If not, can I send data on a separate thread than receive?
The docs for std.socket say nothing of it
Can I send data over an std.socket on multiple threads without
manual mutexing?
If not, can I send data on a separate thread than receive?
The docs for std.socket say nothing of it (which I guess means I
should assume it is not thread safe but...).
Thanks!
On Tuesday, 19 January 2016 at 23:36:14 UTC, Adam D. Ruppe wrote:
On Tuesday, 19 January 2016 at 22:12:06 UTC, Soviet Friend
wrote:
I don't care if my computer needs to do math on a 4 byte
basis, I'm not writing assembly.
x86 actually doesn't need to do math that way, if you were
writing asse
On Tuesday, 27 February 2018 at 22:13:05 UTC, Jonathan wrote:
Is it possible to cast a 2d static length array to a 1d static
length array?
E.g.
int[2][2] a = [[1,2],[3,4]];
int[4]b = cast(int[4])a;
Is not the byte data in memory exactly the same?
*( [pos,size].ptr .cst!(void*) .cst!(int[
Is it possible to cast a 2d static length array to a 1d static
length array?
E.g.
int[2][2] a = [[1,2],[3,4]];
int[4]b = cast(int[4])a;
Is not the byte data in memory exactly the same?
On Tuesday, 27 February 2018 at 16:18:43 UTC, Stefan Koch wrote:
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
I know Python's `with` statement can be used to have an
automatic close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()`
I know Python's `with` statement can be used to have an automatic
close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()` called automatically
```
I know D's `with` statement does something different but is there
some sort of equivalent?
On Saturday, 24 February 2018 at 03:04:07 UTC, Adam D. Ruppe
wrote:
On Saturday, 24 February 2018 at 02:54:13 UTC, Jonathan wrote:
I am having trouble finding many useful explanations of using
template constraints beyond basic usage.
The constraint is just like static if as to what it allows
I am having trouble finding many useful explanations of using
template constraints beyond basic usage.
I would like to have a template constrant to enforce that a type
can be explicitly cast to another type:
void (T)(T t)
if (cast(int) T)//force `cast(int) T` to be possible
I am trying to make a `Pos` type. But I need it to implicitly
cast from an `int[2]`.
I am using the `alias this` to get most of what I want but it
still doesn't do all an implicit cast can do.
What I have now is this:
struct Pos {
int[2] pos;
alias pos this;
this (int
static if (is(T == V))
Are static ifs always checked outside of runtime? Is it possible
for a static if condition to be undeterminable outside of
runtime, or would such a condition throw a compiler error?
What's the best way to do this? I'm assuming this should be best
practice:
http://dlang.org/traits.html#isSame
struct S { }
writeln(__traits(isSame, S, S));
Try:
enum RunOpt { opt1, opt2, opt3 } // No semicolon here
final switch (option) with (RunOpt) {
case opt1: fun1(...); break;
case opt2: fun2(...); break;
case opt3: fun3(...); break;
}
Bye,
bearophile
My hero.
Here's the setup, I have a function
void main { ... }
The main method parses input (via std.getopt) and calls one of
three void-return-type functions. The program's three options
correspond to significantly different initialization options.
In the code we then have:
enum RunOpt {op
24 matches
Mail list logo