I've been using patterns such as this with no difficulty.
ctfe+mixins == it just works.
I don't know if there's some character limit where eventually the
ctfe string return will give up, but for moderate programs it
seems fine.
```d
// Copy fields from another struct, wrapping non-primary key
On Saturday, 29 June 2024 at 23:33:41 UTC, solidstate1991 wrote:
My question is can I initialize structs like these in one line
without relying on a second line?
```d
template ValueOfUDAType(alias T, alias UDA) {
static foreach (uidx, U; __traits(getAttributes, T)) static if
(is(typeof(U) ==
On Thursday, 9 May 2024 at 18:48:12 UTC, Nick Treleaven wrote:
We have a tool in our box already called `true` and that
solves the problem. If we had to type out the full name of
every argument passed to every function ever written we may as
well just adopt ObjC Cocoa style and call it
StopW
On Wednesday, 8 May 2024 at 10:24:07 UTC, Nick Treleaven wrote:
On Wednesday, 8 May 2024 at 04:27:13 UTC, cc wrote:
It doesn't allow a simple boolean to be used as an argument,
or any other Flag as they are different instantiations of a
template rather than equivalent aliases.
It is ho
On Monday, 6 May 2024 at 17:55:49 UTC, user1234 wrote:
I think this just works:
```d
enum Flag : bool
{
no,
yes
}
```
...
must be a reason but I cant find it RN ;)
In "properly" designed Phobos packages, it's unambiguous. Take
for example std.datetime.stopwatch:
```d
import std.typ
On Wednesday, 24 April 2024 at 05:08:25 UTC, Salih Dincer wrote:
Yes, `opApply()` works! You just need to use `do while()`
instead of `while()` because it skips the first item.
It depends on the type of structure being consumed, if it
provides "next" as a direct pointer then yeah you would nee
On Monday, 22 April 2024 at 11:36:43 UTC, Chloé wrote:
I wish to adapt this interface to a forward range for use with
foreach and Phobos' range utilities. This amounts to
implementing empty, front, and popFront, in terms of next and
some state. But there is a choice to be made regarding the
fi
On Wednesday, 17 April 2024 at 03:13:46 UTC, Liam McGillivray
wrote:
On Wednesday, 17 April 2024 at 02:39:25 UTC, Paul Backus wrote:
This is called [row polymorphism][1], and it does not exist in
D.
You could approximate it by making `someFunction` a template,
and accepting any type `T` that
On Monday, 1 April 2024 at 04:54:46 UTC, cc wrote:
I scoured [Traits](https://dlang.org/spec/traits.html) and
[std.traits](https://dlang.org/phobos/std_traits.html) looking
for a simple method to tell whether a member was declared as
enum but couldn't find one, so if anyone knows a prope
On Thursday, 28 March 2024 at 17:23:39 UTC, Andy Valencia wrote:
I wanted a lightweight and simpler CSV decoder. I won't post
the whole thing, but basically you instantiate one as:
That's pretty much the best way to do it. While `.tupleof` does
look kind of hacky, and you could instead itera
On Thursday, 14 March 2024 at 23:19:37 UTC, Inkrementator wrote:
I am trying to derive a struct from another. I want to modify
each field such that type of it goes from some T to Nullable!T,
preserving all fieldnames and UDAs.
This is trivially easy if your types are visible at module level,
On Saturday, 9 March 2024 at 22:03:34 UTC, Liam McGillivray wrote:
Secondly, I found out that interfaces can't have variables.
What!? That's crazy! Why wouldn't they? They totally should.
Doesn't this mean that I will need to use getter and setter
functions instead of direct access when using i
On Friday, 8 March 2024 at 06:03:51 UTC, Liam McGillivray wrote:
A problem I have is that the 3 classes Map, Tile, and Unit
reference each-other. If I turn Map into a template, than it
complains about the member variable of Unit declared as `Map
map;` without arguments. I change this line to `M
On Thursday, 7 March 2024 at 00:38:30 UTC, Richard (Rikki) Andrew
Cattermole wrote:
On 07/03/2024 1:28 PM, Carl Sturtivant wrote:
On Wednesday, 6 March 2024 at 23:45:00 UTC, H. S. Teoh wrote:
In D, there's a pointer to the vtable and another pointer to
a Monitor object (used for synchronized m
On Sunday, 25 February 2024 at 01:19:15 UTC, Lysander wrote:
On Friday, 23 February 2024 at 23:18:12 UTC, kdevel wrote:
How do I search for
i"
in the forum? I get the following errors:
i" -> Error: malformed MATCH expression: [i"] (1)
i\" -> Error: malformed MATCH expression: [i\"] (
On Tuesday, 4 February 2014 at 13:02:26 UTC, TheFlyingFiddle
wrote:
I'm trying to find my own ip address using std.socket with
little success. How would i go about doing this? (It should be
a AddressFamily.INET socket)
On Windows, you can use the Win32`GetAdaptersInfo`[1] function to
get a li
On Thursday, 11 January 2024 at 12:45:45 UTC, cc wrote:
I don't use the delegate version personally, but if that's
already working for you, may as well stick with it.
In retrospect, that delegate version is probably quite a bit
better.
On Sunday, 7 January 2024 at 09:49:36 UTC, Renato wrote:
Hi, I wanted to customize the toString implementation for my
structs.
So I wrote a mixin for doing that:
Alternative format similar to what you already have:
```d
import std.format;
mixin template ToStringMixin() {
void toStrin
On Thursday, 14 December 2023 at 09:38:30 UTC, Joel wrote:
On Thursday, 14 December 2023 at 08:47:49 UTC, Anonymouse wrote:
On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote:
https://dlang.org/phobos/std_path.html#isValidPath
https://dlang.org/phobos/std_path.html#.isValidFilename
Oh,
On Tuesday, 12 December 2023 at 09:43:39 UTC, Joel wrote:
I've got this mixin thing, I think it's less typo-prone. I
haven't been able to make it show the variable's name, though.
Also, it should be optional whether it prints anything, (it's
not hard for me to do that though).
```d
// mixin(j
On Sunday, 1 May 2016 at 09:42:37 UTC, ParticlePeter wrote:
I am logging arbitrary POD struct types with member names and
data:
void printStructInfo( T )( T info ) {
foreach( i, A; typeof( T.tupleof )) {
enum attribName = T.tupleof[i].stringof;
writefln( "%s : %s", attribName, mixin(
On Thursday, 5 October 2023 at 20:42:26 UTC, mw wrote:
On Thursday, 5 October 2023 at 20:07:38 UTC, user1234 wrote:
No. Sorry.
Generally compile time code cannot interact with the system.
To be evaluable at compile time code has to be strongly pure,
that is not the case of the function you wo
On Friday, 25 August 2023 at 21:00:08 UTC, Guillaume Piolat wrote:
The idea is to deliberately mark @system functions that need
special scrutiny to use, regardless of their memory-safety.
Function that would typically be named `assumeXXX`.
...
That way, @safe code will still need to manually @t
On Monday, 11 September 2023 at 17:51:04 UTC, BoQsc wrote:
I would like to set function's default struct for a function in
a way that it would be visible for the reader to see what
options are set. Something like `Options option =
{silenceErrors: false}`
If the function's defaults will always
On Monday, 24 July 2023 at 09:29:09 UTC, Richard (Rikki) Andrew
Cattermole wrote:
There isn't a huge concern with which one you use.
Its quite common to use dmd for development, and ldc for
release for example.
They all share the same frontend, so they really only differ
between them by thei
On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote:
How do I generate `setX` methods for all private mutable
variables in my class? Do I need to use `__traits`?
```d
mixin template GenerateSetters() {
static foreach (idx, field; typeof(this).tupleof) static if
(__traits(getVisibility,field
On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote:
What are your thoughts about using GC as a library writer?
If your program runs, does some stuff, and terminates, use the GC.
If your program runs, stays up for a while with user occasionally
interacting with it, use the GC.
If your prog
On Friday, 11 November 2022 at 01:09:54 UTC, torhu wrote:
On Thursday, 10 November 2022 at 21:55:26 UTC, torhu wrote:
I'm trying to make a more thread-safe wrapper for AA's:
```
synchronized final class SyncAA(K, V) ///
I chose to fix this by just using `synchronized (this)` inside
each meth
Catching up on the DConf '22 videos, really enjoyed the tricks
Walter presents here for no-allocation strings:
[DConf '22: Strawberries and Cream aka Delightful Emergent
Properties of D -- Walter
Bright](https://www.youtube.com/watch?v=iuP-AWUyjp8)
In the Q&A segment, the first question aske
Why is Foo never deallocated here? (`DMD32 D Compiler
v2.099.0-dirty` win64)
```d
class Foo {
string s;
static size_t count, alloced, dealloced;
this() {
"+Foo".writeln;
count++;
alloced++;
}
~this() {
On Saturday, 3 September 2022 at 14:37:16 UTC, Steven
Schveighoffer wrote:
On 9/2/22 3:15 PM, cc wrote:
Tried casting away shared as a workaround but I assume that
will cause some kind of TLS catastrophe.
I think it will be fine, but you may have an issue. You are
returning a non-shared
```d
synchronized class SyncTable(KEY, VAL) {
private VAL[KEY] table;
auto require(KEY key) {
return table.require(key);
}
}
auto table = new shared SyncTable!(string, string);
table.require("abc");
```
Fails to compile:
```
// Error: none of the overloads
On Sunday, 3 July 2022 at 09:43:20 UTC, frame wrote:
app.d:
```d
module app;
import dimedll;
import std.stdio;
import std.stdio : log = writeln;
pragma(lib, "dimedll.lib");
void main() {
log("Lets build our own ime");
testFunc();
}
```
You should be able to change contents
```d
import std.traits;
class XML {}
class Def {
@XML {
int x;
int y;
}
int z;
this() {
static foreach (sym; getSymbolsByUDA!(Def, XML)) {
}
}
}
void main() {
auto def = new Def;
}
``
On Tuesday, 24 May 2022 at 02:55:06 UTC, Tejas wrote:
On Tuesday, 24 May 2022 at 02:29:38 UTC, cc wrote:
```d
import core.memory;
import core.stdc.stdlib : malloc, free;
import core.lifetime : emplace;
[...]
FWIW your code will compile if you add `extern(C++)` to `Foo`
Interesting, thanks
```d
import core.memory;
import core.stdc.stdlib : malloc, free;
import core.lifetime : emplace;
T NEW(T, Args...)(auto ref Args args) /*@nogc*/ if (is(T ==
class)) {
enum size = __traits(classInstanceSize, T);
void* mem = malloc(size);
scope(failure) free(mem);
On Monday, 16 May 2022 at 15:08:15 UTC, H. S. Teoh wrote:
If you find yourself having to cast to/from immutable, you're
using it wrong.
I clearly was, which is why I'm not using it anymore.
The question was "What are you stuck at? What was the most
difficult features to understand? etc.", so I
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
What are you stuck at? What was the most difficult features to
understand? etc.
To make it more meaningful, what is your experience with other
languages?
Ali
Immutability. Ended up having to do so many hundreds of casts to
and
The MemUtils package offers a `ScopedPool` utility that seems
interesting. It isn't well documented however so I have no idea
if it actually works like I expect. I presume this would work
something akin to a VM memory snapshot/rollback for the GC? It
would be pretty handy for some scenarios,
On Wednesday, 4 May 2022 at 05:37:49 UTC, forkit wrote:
inscope int[] i = new int[1];
You often see the "here's an array of ints that exists only in
one scope to do one thing, should we leave it floating in memory
or destroy it immediately?" as examples for these GC discussions.
Not
On Tuesday, 3 May 2022 at 17:05:09 UTC, H. S. Teoh wrote:
Oops, sorry, I made a mistake. The definition of Serializable
should be:
class Serializable(Base, Derived = Object) : Base {}
There we go, works with this, now I get what it's trying to do:
```d
class Serializable(Base, Derived
On Tuesday, 3 May 2022 at 16:51:33 UTC, H. S. Teoh wrote:
On Tue, May 03, 2022 at 04:38:23PM +, cc via
Digitalmars-d-learn wrote:
On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote:
>class Base : Serializable!(Base) { ... }
>class Derived : Serializable!(Base, D
On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote:
class Base : Serializable!(Base) { ... }
class Derived : Serializable!(Base, Derived) { ... }
This is really interesting syntax, I'm surprised that works!
3 May 2022 at 12:46:56 UTC, Adam D Ruppe wrote:
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote:
something I can pass to `Object.factory`.
Object.factory is useless and will hopefully be removed someday.
Instead, make your own factory registration function.
Put a static constructor in the c
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote:
Given a runtime typeid, how can I get the equivalent
fullyQualifiedName without attempting to mangle the string
myself manually? e.g. something I can pass to `Object.factory`.
Actually, looking at this further, does Object.factory even
This produces compatible strings between symbol and runtime type:
```d
class Foo {}
void main() {
alias Foo F;
writeln(fullyQualifiedName!F);
auto f = new F;
writeln(typeid(f).name);
}
```
```
test.Foo
test.Foo
```
But if the class is a template, the strings differ
On Tuesday, 26 April 2022 at 22:16:01 UTC, cc wrote:
Test application:
I should point out that all this stuff with saving refcounted
things to arrays and so on is extremely untested and experimental🙄
One problem I'm seeing is the inability for a refcounted class to
pass itself to an
On Tuesday, 26 April 2022 at 21:33:43 UTC, Chris Katko wrote:
I swear I asked something like this before years ago but it
doesn't show up in my previous forum posts.
I'm looking for a construct that mimics using(var)/with(var)
```d
void draw_with(bitmap* drawb, void delegate() dg) {
s
On Tuesday, 26 April 2022 at 06:55:34 UTC, Alain De Vos wrote:
Can someone provide a simple/very simple reference counting or
refcounted example i can understand. Thanks.
I've been playing around with the automem[1] library's RefCounted
feature as we speak, it seems to fit my needs more than
On Monday, 25 April 2022 at 15:23:12 UTC, Ali Çehreli wrote:
auto arr = iota(10).map!(i => Foo(i.text)).array;
On Monday, 25 April 2022 at 16:11:47 UTC, rassoc wrote:
Foo[] arr = ["abc", "def", "ghi"].map!Foo.array;
Ahh that'll do it alright, thanks
Hard to word this question right, but is it possible to get the
UDAs assigned to a class/structure's member variable declaration,
within that variable's definition? e.g.
```d
import std.stdio;
import std.traits;
enum SPECIAL;
struct Foo {
void foo() {
static if (hasUDA!
On Monday, 25 April 2022 at 01:40:01 UTC, Alain De Vod wrote:
Following program is a single linked list.
We expect as output 1 2 3 1 2 3
But the output is only 1 2 3
```
If you don't need List to be treated as a true range, but just
want to iterate, a simple way to do this is with opApply:
ht
On Monday, 25 April 2022 at 15:13:51 UTC, Stanislav Blinov wrote:
Make it explicit:
```d
Foo[] foos = [Foo("a")];
```
There's that too, but I still have to iterate manually. e.g.:
```d
string[] ss = loadABunchOfStringsFromSomewhere();
//Foo[] foos = ss; //error
Foo[] foos;
foos.reserve(ss.len
On Monday, 25 April 2022 at 15:00:13 UTC, Alain De Vos wrote:
Not really an answer but this works,
```
void main(){
Foo foo = "a";
Foo[] foos;
foos ~=foo;
}%
```
Right, I can append individual elements, but can't assign or
append a slice of a type that can be individually cast to the
struct.
```d
struct Foo {
string s;
this(string s) { this.s = s; }
}
Foo foo = "a";
Foo[] foos = ["a"]; // Error: cannot implicitly convert
expression `["a"]` of type `string[]` to `Foo[]`
Foo[] foos = cast(Foo[]) ["a"]; // Error: e2ir: cannot cast `"a"`
of type `string` to type `Foo`
`
On Monday, 18 April 2022 at 10:26:16 UTC, HuskyNator wrote:
On a sidenote, I'm surprised D did not choose 0 as the default
floating value. Doesn't almost every language do this? I
understand the thinking behind it, but when the type one uses
in a template influences the behavior of the code, th
On Monday, 18 April 2022 at 03:21:30 UTC, H. S. Teoh wrote:
Structs in D ought to be treated like "glorified ints", as
Andrei puts it. If you need complex ctors and complex methods,
that's a sign you should be using a class instead.
Unless you're having a nice quiet get-together with friends,
Another option for this was suggested here:
https://forum.dlang.org/post/qbvgboihhwcuqglyg...@forum.dlang.org
On Wednesday, 12 February 2020 at 09:28:15 UTC, Simen Kjærås
wrote:
So, you could have a file called 'versions' containing this:
# Setting 'Compress' version
-version=Compress
# Optio
On Tuesday, 22 March 2022 at 07:18:00 UTC, cc wrote:
On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote:
Hi, I also need a function to "unquote" string, like this:
```d
assert(unquote(`\n`)=="\n");
```
Is there a way to do that?
I rolled my own for that recently:
```d
s
On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote:
Hi, I also need a function to "unquote" string, like this:
```d
assert(unquote(`\n`)=="\n");
```
Is there a way to do that?
I rolled my own for that recently:
```d
string dequote(string str) @safe pure {
if (str.length < 2)
Sorry for the fairly lengthy post. I'm wondering if there are
any suggested good practices in place for calling templated
functions using the runtime type of an object, e.g. what
`typeid(object)` returns.
Consider the following situation:
```d
class Person {
string name;
int ag
```d
struct A {}
class B {
A opCast(T : A)() {
return A();
}
}
void main() {
auto b = new B();
destroy(b);
}
```
fails with
```
dmd2\windows\bin\..\..\src\druntime\import\object.d(4209): Error:
template instance `opCast!(void*)` does not match templ
On Tuesday, 20 July 2021 at 09:24:07 UTC, Mark Lagodych wrote:
Is there a way to make myvar local to each instance of `X`
without making it a variable of `X`? Just curious.
Sorry if I missed something obvious but is there a specific
reason why it isn't just a class member variable?
```d
class
On Sunday, 13 June 2021 at 21:13:33 UTC, frame wrote:
On Sunday, 13 June 2021 at 10:02:45 UTC, cc wrote:
it seems to work as expected with the same C# code. Does D
explicitly disallow slices as an extern(C) export parameter
type?
The spec says that there is no equivalent to type[]. You get
D under dmd/Win10/64-bit currently seems to store strings
(slices) internally like so:
```d
static struct DString {
size_t length;
immutable(char)* ptr;
}
static assert(DString.sizeof == string.sizeof);
string s = "abcde";
DString d;
memcpy(&d, &s, s.sizeof);
assert(d.length == s.
On Wednesday, 2 June 2021 at 17:50:13 UTC, Sean wrote:
On Wednesday, 2 June 2021 at 15:32:38 UTC, Sean wrote:
if so, how can I get the behavior i am searching for? Thank
you.
My current solution, if anyone wonders :
https://github.com/patefacio/d-help/blob/master/d-help/opmix/dup.d
You may
On Tuesday, 1 June 2021 at 20:20:34 UTC, Ola Fosheim Grøstad
wrote:
Web components are becoming a reality, it essentially means
that you have code and styling wrapped up as a component, so
that you can use it by inserting a custom html-tag in your
code. Given the massive amount of web developer
This is overkill for any reasonable application, but I've always
wanted to design a whole UI framework in OpenGL, just for the
novelty of it. I always end up having to reinvent the wheel for
UI elements in my projects anyway.
https://streamable.com/2uvt4h
On Thursday, 27 May 2021 at 20:46:22 UTC, Adam D. Ruppe wrote:
On Thursday, 27 May 2021 at 20:44:21 UTC, frame wrote:
Did you mean to add the delegate as GC root or the data?
The delegate.ptr property.
Is there any way to enforce at compile time that we're not
accidentally allocating when c
On Saturday, 22 May 2021 at 03:14:35 UTC, cc wrote:
Oops, disregard this. I had an error in my imports.😓
It does in fact work in @safe.
I should add as an aside then that there is an issue of errors
from the body of a toString template not being displayed, and
instead the template being
On Saturday, 22 May 2021 at 03:07:10 UTC, cc wrote:
Ahh, in that case it would appear formattedWrite isn't @safe at
all. Looks like you have to stick with put()?
```d
@safe void toString(W)(ref W writer) if (isOutputRange!(W,
char)) {
//writer.formattedWrite!("FOO:%s"
On Friday, 21 May 2021 at 16:53:48 UTC, drug wrote:
21.05.2021 18:28, cc пишет:
On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote:
Thank you, and formatValue?
formattedWrite should handle this.
```d
@safe struct Foo {
int x = 3;
void toString(W)(ref W writer) if (isOutputRange
On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote:
Thank you, and formatValue?
formattedWrite should handle this.
```d
@safe struct Foo {
int x = 3;
void toString(W)(ref W writer) if (isOutputRange!(W, char)) {
writer.formattedWrite("Foo(%s)", x);
}
}
On Saturday, 15 May 2021 at 18:24:19 UTC, Alain De Vos wrote:
Thanks, good idea but,
It does not initiate a GC cycle or free any GC memory.
Personally I wish D would re-implement "delete" and make it "just
work" like one would assume, but from what I've seen there have
been many many debates
Are these identical? Or is there a different usage for the (T :
something) form?
```d
auto opCast(T)() if (is(T == bool)) {
return _obj !is null;
}
```
```d
auto opCast(T : bool)() {
return _obj !is null;
}
```
On Friday, 14 May 2021 at 15:30:06 UTC, Imperatorn wrote:
https://www.amazon.com/Programming-Language-Former-Python-Developers-ebook/dp/B08MD7ZB2X
Anyone read it?
Haven't read it, the title has me at the first five words though.
On Thursday, 13 May 2021 at 16:40:29 UTC, Imperatorn wrote:
Wouldn't this just this do that? 🤔
```d
string dequote(string s)
{
return s[1..$-1];
}
```
The idea would be for situations where it isn't known in advance
whether the string is quoted, if it is quoted properly, and
whether ther
Does something to dequote (unquote? or what would you call it?) a
string exist in the standard library? I didn't see one in
std.string, just wondering before reinventing the wheel.
Something like:
```d
assert(dequote(`"foo"`) == "foo");
assert(dequote(`'foo'`) == "foo");
assert(dequote(`"foo's
On Tuesday, 11 May 2021 at 09:10:02 UTC, Vinod K Chandran wrote:
Hi all,
I am practising D with a win api GUI hobby project.
I have a Window class and it resides in module window.d
My WndProc function resides in another module named
wnd_proc_module.d
Inside my WndProc, I get the Window class li
On Sunday, 2 May 2021 at 02:42:46 UTC, Adam D. Ruppe wrote:
On Sunday, 2 May 2021 at 02:34:41 UTC, cc wrote:
which seems to fix it, but I'm not entirely sure what's going
on, if this is expected behavior, if that's the correct way to
handle it, and so on.
Oh I've been
On Sunday, 2 May 2021 at 02:34:41 UTC, cc wrote:
[...]
Just to add, only appending to the array seems to give
OutOfMemoryErrors. I can idup strings, call stdc malloc, etc
just fine.
Ordinarily, it seems legal to append to an array that has been
declared at module level (or as a static class member) that
hasn't been otherwise initialized, for example:
```d
class Foo {}
private Foo[] cache;
void main() {
auto foo = new Foo();
cache ~= foo;
}
```
However, when
On Monday, 26 April 2021 at 13:44:19 UTC, frame wrote:
On Sunday, 25 April 2021 at 15:01:25 UTC, cc wrote:
Adding a note in case anyone stumbles across this with a
similar problem:
Adding `stdout.setvbuf(0, _IONBF);` to both the main and DLL
will cause D to autoflush after every write call
On Monday, 19 April 2021 at 18:32:15 UTC, Adam D. Ruppe wrote:
On Monday, 19 April 2021 at 18:05:46 UTC, cc wrote:
This seems to work if I flush after every printf or write in
both main and the dll. I was under the impression they were
supposed to share the same IO buffers though, is this not
On Monday, 19 April 2021 at 16:04:28 UTC, Mike Parker wrote:
On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote:
And upon running, the output I receive is:
```
[Main] Start
[Main] x: 5
[Main] Finished
[Main] END
[dll] DLL_PROCESS_ATTACH
[dll] static this for mydll
[dll] MyDLL_Test
[dll
On Monday, 19 April 2021 at 16:00:25 UTC, frame wrote:
You miss a core.stdc.stdio import in main().
I also omit the def-File, maybe you have an error in it? It
shouldn't be necessary to include. It just did:
```
dmd -m64 -ofmydll.dll -L/DLL mydll.d
```
Sorry, here's the def file, taken from t
I'm not sure if this is something unique to D or not, but I've
having a minor issue where stdout output from a DLL (either via
printf or phobos std.stdio write) is not displayed until after
the main process has completed. I'm making a project based
around the example at https://wiki.dlang.org/
Just encountered this compilation failure in DMD winx64 2.096,
which previously worked in 2.095 and prior versions. Just
wondering if it's a bug, or a new issue to keep in mind when
importing modules? Sorry for the complex nature of this scenario
but I'll try to keep it as simple as possible.
On Tuesday, 12 January 2021 at 21:32:14 UTC, Ali Çehreli wrote:
On 1/12/21 12:58 PM, cc wrote:
> void send(T query, void delegate(T.RESPONSE) callback) {
That wants a delegate that takes a T.RESPONSE (PingResponse in
this case). However, the following lambda is in fact a templ
Given the following program:
struct PingQuery {
string msg;
}
struct PingResponse {
string msg;
}
template send(T) {
void send(T query, void delegate(PingResponse) callback) {
writefln("Sending: %s", query);
if (callback) {
On Tuesday, 12 January 2021 at 20:19:20 UTC, ag0aep6g wrote:
On 12.01.21 21:09, cc wrote:
import core.sys.windows.windows;
import mymodule; // contains a struct named MSG
Error: `core.sys.windows.winuser.MSG` ... conflicts with
`mymodule.MSG`
vs
import core.sys.windows.windows : winMSG
Is it possible to import all symbols of a module, while renaming
just one of them? It seems like doing an import with renaming
automatically makes it selective.
In the example below, I'd prefer not to have to use the fully
qualified name for mymodule.MSG every time e.g.:
import core.sys.windo
On Wednesday, 8 July 2020 at 02:06:01 UTC, Steven Schveighoffer
wrote:
OK, so I have a situation where I'm foreaching over a
compile-time list of types. Inside the loop, I'm using a second
loop over a set of input.
Inside that loop, I'm using a switch on the input, and inside
the switch, I'm
This compiles:
class Foo {
int x;
@(1) void y() {}
this() {
static foreach (idx, field; getSymbolsByUDA!(Foo, 1)) {
}
}
}
This does not:
class Foo {
@(1) int x;
void y() {}
this() {
static fo
On Monday, 17 February 2020 at 17:01:12 UTC, Adam D. Ruppe wrote:
It sometimes helps to write it out log-form
foo.opDispatch!"hello"(5);
should give the full error.
this btw is one of the most annoying missing errors in d...
This worked, thank you!
On Monday, 17 February 2020 at 16:45:53 U
Is there any way to see the compilation errors that occurred
within an opDispatch template?
struct Foo {
void opDispatch(string s, SA...)(SA sargs) {
literally anything;
}
}
Foo foo;
foo.hello(5);
Result: Error: no property `hello` for type `Foo`
Desired result
Here's a more involved example of what I'm trying to accomplish.
Is there an easier/cleaner way to do this? (This is still a bit
reduced, what I'm actually trying to do is compare whether a
given variadic typetuple passed to opDispatch is implicitly
convertible to one of the parameter definit
import std.meta;
enum A = AliasSeq!(1, 2, 3, 4);
THREELOOP: static foreach (idx, field; A) {
static if (field == 3) {
pragma(msg, "Got a 3!");
break THREELOOP;
}
static if (idx == A.length - 1) {
static assert(0, "Got no 3..."
On Wednesday, 12 February 2020 at 09:28:15 UTC, Simen Kjærås
wrote:
https://dlang.org/dmd-windows.html#switches
specifies that DMD may be passed a file on the command line
that contains compiler arguments and switches. This may be
freely combined with regular command line arguments if you so
It looks like 004 (octal) is the flag for directories on
linux, but it does seem that std.zip is explicitly returning 0 if
the file was created on the opposite platform re: Posix vs
Windows, which is... odd.
@property @nogc nothrow uint fileAttributes() const
{
version (Posix)
{
1 - 100 of 139 matches
Mail list logo