On Monday, 28 April 2025 at 04:59:24 UTC, Orion wrote:
At the compiler level, enum lambda is represented as a literal.
But how is alias represented? As an expression?
A lambda is basically syntax sugar for a local function
declaration. So when you write this:
fun((float x) => 0.5 + x);
On Tuesday, 15 April 2025 at 21:06:30 UTC, WhatMeWorry wrote:
I had assumed that ref keyword negated the use of * and &
operators but when I try to use it, DMD is saying "only
parameters, functions and `foreach` declarations can be `ref`".
Fair enough. I thought that the * and & operator was fo
On Sunday, 13 April 2025 at 17:28:12 UTC, Salih Dincer wrote:
Hi,
Please watch: https://youtu.be/siw602gzPaU
If he had learned this method like me, he would not have needed
if's and long explanations. :)
It's a very redundant thing (ASCII magic) that also weeds out
the incompatible characte
On Tuesday, 1 April 2025 at 09:21:25 UTC, Daniel Donnelly, Jr.
wrote:
Something like this. I know I could very well hash latex
member, but what if the user redefines toString() ? So I would
like to call toString(), but DMD compiler bitches:
```
Error: @safe function def.Def.toHash cannot cal
On Saturday, 22 March 2025 at 12:05:11 UTC, Ali Çehreli wrote:
On 3/21/25 8:35 PM, Andy Valencia wrote:
> tst39.d(21):add `alias this = tst39.A.this` to
`tst39.B`'s body
> to merge the overload sets
Yeah, that doesn't work. Perhaps a regression...
It's never worked. The error message
On Thursday, 20 March 2025 at 02:01:25 UTC, Jonathan M Davis
wrote:
On Wednesday, March 19, 2025 5:48:37 PM MDT H. S. Teoh via
Digitalmars-d-learn wrote:
I thought it was always a miss. :-D At least, it's never
worked for me every time I tried it. I always have to move
the UFCS function to mo
On Monday, 17 March 2025 at 12:28:38 UTC, Maximilian Naderer
wrote:
Hello people,
i have the following example. Compiled with dmd and ldc2
dmd main.d -betterC
ldc2 main.d -betterC
with dmd the compilation fails with
lld-link: error: undefined symbol: _memsetFloat
>>> referenced by app
On Monday, 10 March 2025 at 13:58:08 UTC, zz wrote:
On Tuesday, 4 March 2025 at 11:25:14 UTC, Paul Backus wrote:
On Monday, 24 February 2025 at 12:53:30 UTC, zz wrote:
Hi,
Is setjmp/longjmp supported under windows?
Regards,
zz
It's a standard C function, and Microsoft's online library
docu
On Saturday, 8 March 2025 at 22:21:45 UTC, Enamisu wrote:
I have errors when working with the `core.sys.windows.winnt`
library. I use dub to compile the program. I don't understand
why dependencies are not imported. Please help me understand
the cause of the error.
It looks like the errors ar
On Thursday, 6 March 2025 at 10:46:20 UTC, tmp wrote:
I come from a C/C++ background where the pointer aliasing rules
make an assumption that pointers to different types cannot
alias each other (with the exception of a pointer to char).
This is known as the strict aliasing rule and while it can
On Wednesday, 5 March 2025 at 16:58:18 UTC, Kirill Kryukov wrote:
Hi all,
I was debugging an old project that started crashing after
upgrading to a recent toolchain. I noticed that commenting out
invariants helps. I reduced it to the following:
[...]
Is this a bug, or am I misunderstanding
On Monday, 24 February 2025 at 12:53:30 UTC, zz wrote:
Hi,
Is setjmp/longjmp supported under windows?
Regards,
zz
It's a standard C function, and Microsoft's online library
documentation says that it's supported, so it should work.
In D, bindings for standard C headers are available in the
On Saturday, 1 March 2025 at 03:13:55 UTC, user1234 wrote:
because the tuple-expression `(0,0.1)` is explicitly
convertible to `Test`, based on the concept of "structural
typing".
Even if D has tuples, I highly doubt that it will have this kind
of implicit conversion from tuples to structs. D
On Saturday, 1 March 2025 at 02:19:55 UTC, Meta wrote:
On Saturday, 1 March 2025 at 00:47:20 UTC, Paul Backus wrote:
What you can do is use curly-brace initialization syntax:
Thanks, I forgot about that syntax. Another question I have is
if there's a way to do this inline:
No, there's no w
On Friday, 28 February 2025 at 23:31:23 UTC, Meta wrote:
```d
struct Test
{
int n;
float f;
static Test opCall(int n, float f)
{
return Test(n, f);
}
}
void main()
{
Test(1, 2.0);
}
```
This code causes an infinite loop because the `Test(n, f)`
inside the stati
On Friday, 21 February 2025 at 07:44:54 UTC, Jonathan M Davis
wrote:
I think that what it basically comes down to is that because -1
fits in int, and int implicitly converts to uint, VRP is fine
with converting the long with a value of -1 to uint. So, as
long as the value fits in 32 bits, the c
On Saturday, 15 February 2025 at 15:40:51 UTC, Dom DiSc wrote:
On Friday, 14 February 2025 at 15:58:26 UTC, Paul Backus wrote:
Oops--it turns out both overloads are equally specialized!
This is what I want to be fixed. For a human it is obvious
which of the two is a better match. Lets add a r
On Friday, 14 February 2025 at 17:29:33 UTC, Andy Valencia wrote:
On Friday, 14 February 2025 at 15:58:26 UTC, Paul Backus wrote:
void foo(long x) { }
void foo(ulong x) { }
So I take it that a template with a static isSigned test would
be the way to bifurcate foo()'s behavior?
Andy
Yes, t
On Friday, 14 February 2025 at 04:28:25 UTC, Dom DiSc wrote:
Why does this happen:
```d
void foo(long x) { }
void foo(ulong x) { }
main()
{
foo(short(17)); // error: `foo` called with argument types
`(short)` matches both: `foo(long x)` and: foo(ulong x)`
}
```
Why does a short match an u
On Thursday, 30 January 2025 at 01:38:07 UTC, Kyle Ingraham wrote:
Does D have a 'try' `std.conv:to` that does not throw if it
fails? Something like:
```D
string input = "9";
int output;
auto parsed = input.tryTo!int(output);
```
You could try something like this:
```d
import std.typecons: Nu
On Tuesday, 21 January 2025 at 09:34:29 UTC, DLearner wrote:
Suppose we have:
```
string str1 = "A" ~ "B";
```
Does that produce:
str1 == x'41' x'42' x'00' or
== x'41' x'00' x'42' x'00' or
== x'41' x'00' x'42' x'00' x'00'?
And is str1.length == 2 or
== 3 or
On Wednesday, 27 November 2024 at 01:12:23 UTC, Andy Valencia
wrote:
Again and again for testing I run into how nice it would be to
have an open "File" which has its contents set by the unit test
code:
auto f = StringFile("my test data...", "r");
I've searched high and low without discoveri
On Tuesday, 26 November 2024 at 04:15:35 UTC, Steven
Schveighoffer wrote:
On Monday, 25 November 2024 at 14:24:44 UTC, Bastiaan Veelo
wrote:
// Fishy:
inout(E) gun(inout(E) e)
{
//writeln(e.to!string); // only parameters or stack-based
variables can be `inout`
writeln((cast(Unqual!E)
On Monday, 25 November 2024 at 14:24:44 UTC, Bastiaan Veelo wrote:
I suspect a bug in conv.to, am I right?
Yes, this is a bug. Because of the weird restrictions on `inout`,
it's very easy to write template code that doesn't handle it
correctly.
On Friday, 22 November 2024 at 16:36:43 UTC, Andrew wrote:
I'm getting started using D for some small personal projects
and one thing I wanted to do was use a helper function for a
tuple. I declared the function like this:
string getOrZeroth(Tuple!(string, string, string) tup, int
i) pure
On Sunday, 3 November 2024 at 19:00:33 UTC, DLearner wrote:
However, the docs say dynamic arrays are not allowed with
betterC, and 'string' implies a dynamic array.
So I expected DMD to complain that my code was invalid.
Any ideas?
The docs are wrong. Dynamic arrays themselves are allowed; yo
On Wednesday, 23 October 2024 at 17:18:47 UTC, Anton Pastukhov
wrote:
On Wednesday, 23 October 2024 at 14:50:44 UTC, Paul Backus
wrote:
You can't use an `alias` to refer to a member variable like
this. When you write
alias myAlias = myStruct.test;
...it is silently rewritten by the com
On Wednesday, 23 October 2024 at 13:00:15 UTC, Anton Pastukhov
wrote:
On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus
wrote:
snip
Thanks, that's a good catch. `alias myAlias = MyStruct.test` is
really just a typo, I meant `alias myAlias = myStruct.test`,
so I actually have an i
On Wednesday, 23 October 2024 at 12:32:09 UTC, Anton Pastukhov
wrote:
I'm struggling with this code. Why `countUntil` won't work with
aliases?
```
import std.traits : EnumMembers;
import std.algorithm : countUntil;
enum Test: string {
One = "one",
Two = "two",
Three = "three"
}
str
On Sunday, 8 September 2024 at 23:01:22 UTC, monkyyy wrote:
On Sunday, 8 September 2024 at 22:01:10 UTC, WraithGlade wrote:
I want to just be able to write this:
```
show!(1 + 2)
```
```d
void show(string s)(){
auto res=mixin(s);
writeln(s,"==",res);
}
show!"1+2";
```
This works for `s
On Sunday, 8 September 2024 at 22:01:10 UTC, WraithGlade wrote:
Basically, I want there to be a way to print both an expression
and its value but to only have to write the expression once
(which also aids refactoring). Such a feature is extremely
useful for faster print-based debugging.
Thus,
On Saturday, 31 August 2024 at 22:06:26 UTC, kdevel wrote:
Is that functionally different from
```
void main()
{
import std.stdio;
int[string] test = ["hello": 42];
if (auto p = "hello" in test)
{
writeln("hello => ", *p);
}
}
```
It's essentially the same. I only
On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote:
```D
void main()
{
int[string] test;
test["hello"] = 42;
if (auto it = "hello" in test)
{
}
}
```
Is there a way to get the value instead of a pointer? while
keeping the conciseness (one line)
Once the next rel
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
```d
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
setIt(*b);
assert(a == 0b); // what actually happens
assert(a == 0b1110); // what would be safe
}
```
On Wednesday, 17 April 2024 at 01:36:59 UTC, Liam McGillivray
wrote:
To better understand what I mean, take the following example,
where I have a function, and two structs.
```
struct typeA {
// Some member variables here
}
struct typeB {
// Some similar member variables here, but in a
On Saturday, 2 March 2024 at 19:29:47 UTC, Per Nordlöw wrote:
On Saturday, 2 March 2024 at 19:28:08 UTC, Per Nordlöw wrote:
On Saturday, 2 March 2024 at 19:11:42 UTC, kinke wrote:
Not according to run.dlang.io, for all available DMD
versions. Perhaps your tested `S` was nested in some
function
On Saturday, 24 February 2024 at 10:31:06 UTC, Liam McGillivray
wrote:
`Unit.d` & `Map.d` are longer files. `Map.d` begins with
`import Tile;`, and `Unit.d` begins with `import Map;`.
Why are the errors happening? What's the problem? Why is it
`currentclass.importedclass` instead of simply t
On Thursday, 15 February 2024 at 18:12:42 UTC, realhet wrote:
Hello,
Today I tried to upgrade my sources to the latest LDC, but
failed with this unfortunate error.
```
import std;
struct S{ E e; }
enum E
{
@S(e2) e1,
@S(e1) e2
}
```
Looks like someone reported a similar bug in 201
On Friday, 9 February 2024 at 08:04:28 UTC, Danilo wrote:
Incredible! Seems like D is experiencing featuritis.
Priorities may be wrong.
Instead of bug fixing and stabilization, people concentrate on
getting new stuff like ˋ:blubˋ into the language.
If you look at the work actually being done i
On Monday, 5 February 2024 at 16:45:03 UTC, Dom DiSc wrote:
Why is real.sizeof == 16 on x86-systems?!?
Its the IEEE 754 extended format: 64bit mantissa + 15bit
exponent + sign.
It should be size 10!
I mean, alignment may be different, but why wasting so much
memory even in arrays?
According
On Friday, 2 February 2024 at 23:25:37 UTC, Chris Katko wrote:
The auto solution won't work for a struct however which I'm
using:
```D
struct procTable{ //contains all the fields inside a file I'm
parsing
uint time;
int priority;
string name;
// etc
}
```
Maybe you can use `t
On Friday, 2 February 2024 at 07:43:09 UTC, Chris Katko wrote:
Is there some way to do:
```D
string[3] data; //strings from some file input, some are ints,
uints, etc.
auto into!(T)(T value){return to!???(value); } // ???
uint time = into!(data[1]); // We already know this is uint
int priorit
On Friday, 2 February 2024 at 20:28:50 UTC, Carl Sturtivant wrote:
On Friday, 2 February 2024 at 19:22:22 UTC, Steven
Schveighoffer wrote:
```d
// shim
auto foo(Args...)(Args args) if (!allSatisfy!(isVariant, Args))
{
mixin("return foo(", argsAsVariants(args.length), ");");
}
```
Thanks fo
On Tuesday, 30 January 2024 at 02:05:23 UTC, user1234 wrote:
I want to share a stupid program to show you that D safety is
more complex than you might think:
```d
module test;
void test() @safe
{
int i;
int b = (*&(*&++i))++;
}
void main() @safe
{
test();
}
```
I'm not showing a
On Thursday, 25 January 2024 at 08:25:02 UTC, atzensepp wrote:
```d
int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
```
This leads to:
```
gdc lambda4.d
lambda4.d:28:25: error: template compose(E)(E a) has no value
int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
```
Try using t
On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote:
It works fine.. but when the variable becomes ``const(Stuff)*
stuff;``
It gives me:
```
onlineapp.d(13): Error: cannot uniquely infer `foreach`
argument types
```
I have no idea what i should be doing, does anyone have a clue?
ht
On Monday, 22 January 2024 at 21:11:17 UTC, NonNull wrote:
I'd like SumType to combine the implicit tags so there's only
one tag.
SumType does not do this automatically (because sometimes you
might want to keep the inner SumTypes separate), but you can do
it yourself like this:
alias
On Wednesday, 17 January 2024 at 18:44:14 UTC, Carl Sturtivant
wrote:
Hello,
I'd like a function like this,
```
string image(string s)
```
that maps any string s into the doubly quoted backslash escaped
text that would be a string literal for s were it pasted into a
program. Perhaps with a seco
On Sunday, 7 January 2024 at 09:49:36 UTC, Renato wrote:
Is the above a "good" way to do this?
It looks ok to me. There are some minor changes I would make,
like using `typeof(this)` instead of `S` to refer to the type of
the struct you're mixing it into, but the overall approach is
fine.
On Friday, 5 January 2024 at 20:41:53 UTC, Noé Falzon wrote:
In fact, how can the template be instantiated at all in the
following example, where no functions can possibly be known at
compile time:
```
auto do_random_map(int delegate(int)[] funcs, int[] values)
{
auto func = funcs.choi
On Wednesday, 27 December 2023 at 20:20:23 UTC, tososdk wrote:
I was recreating some code from C++ to D:
[...]
But since I am somewhat new to these topics and even more so to
Dlang, I don't understand very well. The problem occurs in the
creation of the .wav, regarding rawWrite, I'm not really
On Wednesday, 27 December 2023 at 15:57:14 UTC, tososdk wrote:
Two things: Could you explain how "inline" works? Is there
something similar in Dlang?
In C and C++, `inline` is a suggestion to the compiler that it
should consider using [inline expansion][1] for calls to a
particular function.
On Tuesday, 12 December 2023 at 14:57:48 UTC, Kevin Bailey wrote:
perm.d:8:26: error: none of the overloads of template
‘std.algorithm.iteration.permutations’ are callable using
argument types ‘!()(char[])’
8 | foreach (perm; as.permutations)
| ^
/usr/
On Monday, 11 December 2023 at 23:21:45 UTC, Quirin Schroll wrote:
I always thought you had to provide aliases with all 16
combinations of the attributes `@safe`, `@nogc`, `pure`, and
`nothrow` for each actually desired instance. But you don’t and
**I have no clue why**.
Why does it work?
T
On Friday, 1 December 2023 at 13:02:06 UTC, Dom DiSc wrote:
```d
S Fun(){ return { 5, 2 }; }
```
This IS an initialization and the type is known. Requiring the
repetition of the type is also here annoying.
Technically you don't *have* to repeat the type. You can write
the return type as `aut
On Wednesday, 29 November 2023 at 17:23:04 UTC, Antonio wrote:
On Wednesday, 29 November 2023 at 16:48:09 UTC, Paul Backus
wrote:
... it even supports named arguments:
- Witch version of DMD supports named arguments? Is it an
experimental compiler option?
I don't know what the earliest ver
On Wednesday, 29 November 2023 at 16:38:36 UTC, Dom DiSc wrote:
```d
struct S2 { int a; int b; this(int c, int d) { a=c; b=d; } }
S2 fun3() { return S2( 5, 2 ); } // works but requires explicit
constructor
```
You can use this syntax without an explicit constructor:
struct S3 { int a; i
On Wednesday, 29 November 2023 at 13:31:14 UTC, DLearner wrote:
```
Error: found `End of File` when expecting `;` following
statement
```
If an extra ; is added:
```
}(` ~ strStartPtr ~ `,` ~ strPLPtr ~ `);`;
```
it works but doesn't seem correct.
This is an annoying limitation of the D
On Thursday, 23 November 2023 at 19:17:20 UTC, Antonio wrote:
Basically, the ternary conditional ```?:``` result type is not
inferred even if the type returned by the two possibilities are
the same.
**Is it a bug or the expected behaviour?**
Known bug, first reported in 2009:
https://issues
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote:
Code below is intended to test simple mixin with lambda
function under -betterC.
Works with full-D, but fails with 'needs GC' errors under
-betterC.
Why is this so, bearing in mind the concatenations are executed
at
compile, not
On Wednesday, 22 November 2023 at 17:53:15 UTC, Antonio wrote:
Basically, it doesn't know witch version of ```filter``` to
use, because it is inferring `i=>i%2==0` is `void` ?!?!?!
```
!()(IIterable!int, void)
```
If I explicitly write `(int i)=>i%2==0`, it compiles correctly
again.
**Is it
On Monday, 20 November 2023 at 16:09:33 UTC, Antonio wrote:
What "breaks" my mind is that a compiler decision (treat a
piece of code as function or delegate) is not completely
transparent causing "side" effects on your code (writeln
doesn't work the same way: it shows the delegate signature,
On Monday, 20 November 2023 at 08:47:34 UTC, Antonio wrote:
- What is the way to do ```writeln``` work with ```Counter```
function the same way it works with ```next``` function?
`writeln(&Counter)` should do it.
On Monday, 20 November 2023 at 08:47:34 UTC, Antonio wrote:
I understand the problem with UFCS (``next`` is not using UFCS
because it is a delegate defined in the own main() function,
and ``Counter``` without () is treated as a function call
because it is UFCS eligible )
This is not UFCS, it
On Tuesday, 14 November 2023 at 14:36:57 UTC, dhs wrote:
Just to clarify some more: isn't "s1 = ss1" similar to
something like:
```d
const(S1) s1;
S1 ss1; // ss1 is now S1.init
S1_copy_construct_const_in_const_out(ss1, s1);
```
If this is the case, the compile error is expected, bu
On Tuesday, 14 November 2023 at 13:43:03 UTC, Hipreme wrote:
Right now, I've been implementing classes separately, and I
need a dummy symbol. The best world is not even having a symbol
but having only its implementation, for example, I would like
being able to do that:
```d
void pragma(mangle
On Tuesday, 14 November 2023 at 13:41:32 UTC, Steven
Schveighoffer wrote:
```
Error: copy constructor `testinoutctor.S1.this(ref const(S1) s)
const` is not callable using argument types `(const(S1))`
```
I'm not sure what this means. There shouldn't be a copy being
made here, as the thing is
On Tuesday, 14 November 2023 at 08:50:34 UTC, dhs wrote:
```d
struct S2
{
this(ref inout S2 s) inout { writeln("copy"); }
int i;
}
void test()
{
const(S1) s1;
S1 ss1 = s1; // error, ss1 not qualified as const
const(S2) s2;
S2 ss2 = s2; // fine, why?
}
```
Isn't "inout"
On Saturday, 11 November 2023 at 01:50:54 UTC, Trevor wrote:
How does one install packages globally, and how can I write
programs that use the third-party packages without being
wrapped in a dub file?
Dub currently isn't able to do this. There's been some discussion
about adding a `dub instal
On Wednesday, 8 November 2023 at 16:30:49 UTC, Bienlein wrote:
Hello,
I get the error "`addToBiz(T)(Biz!T biz)` is not an lvalue and
cannot be modified" when compiling the code below. Can't find a
way how to do it right. Am a D newbie and would appreciate some
help.
[...]
static void a
On Monday, 6 November 2023 at 05:30:02 UTC, zoe wrote:
I customized object.d in -betterc mode and created NEW
templates, with modules I can seemingly create classes without
extern(C++) mode, and type conversions in function calls seem
to work fine. But when destroy doesn't find a way to call th
On Sunday, 5 November 2023 at 18:36:40 UTC, Ctn-Dev wrote:
I wrote this earlier:
[...]
`if` runs when both "One" and "Two" are in the given array as
intended, but its conditional statement looks verbose. Is there
a more concise way of getting the same result?
If sorting the arrays is an opt
On Saturday, 4 November 2023 at 03:00:49 UTC, Dadoum wrote:
I was wondering why C++ linkage forbids strings as arguments
while we can with the C one.
With C linkage, it's translated to a template that's defined in
the automatically generated header, but it just doesn't compile
in C++.
`exte
On Thursday, 2 November 2023 at 12:52:35 UTC, BoQsc wrote:
Therefore the need to import `package.d` is needed and I can't
see a solution, which means
that D Language might have to introduce a way to import
`package.d` from inside the package, if there is a need to
further improve experience of
On Thursday, 2 November 2023 at 11:12:58 UTC, BoQsc wrote:
Weirdly enough it does not work on Windows operating system.
[...]
```
program.d(1): Error: unable to read module `waffles`
program.d(1):Expected 'waffles.d' or
'waffles\package.d' in one of the following import paths:
import pa
On Sunday, 22 October 2023 at 21:02:32 UTC, Inkrementator wrote:
Running the code with `rdmd -version=fix app.d` works, but
running `rdmd -version=fix app.d` produces:
`Error: field `member` must be initialized in constructor,
because it is nested struct`
Why?
I didn't find anything about this
On Monday, 16 October 2023 at 03:31:13 UTC, dan wrote:
I have some code that i would like executed before anything
else is.
The code is to set an environment variable which is used by a
library. I'm trying to find some way to avoid setting the
environment variable on the command line, or in
On Tuesday, 3 October 2023 at 18:29:49 UTC, Salih Dincer wrote:
More importantly, is there a priority order? Because in our
last example, when we leave a single overload, all features are
executed through the ref opIndex except the bit:
The spec says:
If an index expression can be rewritten
On Tuesday, 3 October 2023 at 17:05:46 UTC, Steven Schveighoffer
wrote:
```d
void main()
{
S s = 0;
{
scope int[] __r3 = s.opIndex()[];
ulong __key4 = 0LU;
for (; __key4 < __r3.length; __key4 += 1LU)
{
On Tuesday, 3 October 2023 at 16:45:39 UTC, Steven Schveighoffer
wrote:
OK, so it's not as bad as I thought, but surely the compiler
should recognize that `opIndexAssign(val, idx)` doesn't work,
but `opIndex(idx) = val` does?
Maybe. On the other hand, if you make a typo in the body of your
On Tuesday, 3 October 2023 at 13:07:00 UTC, Steven Schveighoffer
wrote:
Now, you can define a further `opIndexAssign(T val, size_t
idx)`. However, now you lose capabilities like `a[0]++`, which
I don't think has a possibility of implementing using an
`opIndex` operator, and it would be pretty
On Monday, 2 October 2023 at 20:34:11 UTC, Salih Dincer wrote:
In an old version (for example, v2.0.83), the code you
implemented in the places where Slice is written above works as
desired. In the most current versions, the parameterized
opIndexAssign(T value) gives the error:
onlineapp.d(5
On Sunday, 1 October 2023 at 17:41:08 UTC, Salih Dincer wrote:
Hi,
What is the difference between T[] opIndex() and T[] opSlice(),
which haven't parameters?
`T[] opSlice()` is the D1 version and exists only for backwards
compatibility. You should use `T[] opIndex()` in new code.
On Sunday, 1 October 2023 at 01:17:50 UTC, Chris Piker wrote:
Hi D
I've a simple question but it's bedeviling me anyway. How do I
get a string representation of the current type of a SumType?
I'm trying to avoid something like this:
```d
alias Vec3 = SumType!(void* /* invalid vector */, by
On Thursday, 14 September 2023 at 14:21:09 UTC, Vino wrote:
Questions:1
```
char[] invalid = (cast(char*)malloc(char.sizeof *
length))[0..length];
```
The above statement allocate memory for char type and the size
of the allocated memory is char.sizeof * length so what is the
use of this "[0.
On Sunday, 3 September 2023 at 10:06:58 UTC, Vino wrote:
Hi All,
As per the documentation from std.process it states that an
exception is thrown if the variable contains invalid UTF-16
characters and it can also be validated using "validate"
function from std.utf, so the question is do we
On Wednesday, 30 August 2023 at 17:48:19 UTC, Vino wrote:
Hi All,
Request your help on hot to create a pointer for a function
whose function type is Result.
```
ReturnType!(typeof(&test)).stringof; // Result
From
Vino
```
To get a function pointer type from a function type, you can add
`
On Sunday, 13 August 2023 at 11:44:50 UTC, IchorDev wrote:
I feel like I can't possibly be the first to ask, but I
couldn't find any prior discussion of this:
When is `std.experimental.allocator` going to be moved out of
`experimental`? Is there any roadmap for it? Is it just in
limbo?
The cu
On Thursday, 27 July 2023 at 21:19:08 UTC, Vijay Nayar wrote:
Attempted Fix 2: Enclose the entire attribute name in
parenthesis.
```
static import vibe.data.serialization;
class ChatCompletionFunctions {
@(vibe.data.serialization.name)("name")
...
}
```
You almost had it. The correct synt
On Friday, 7 July 2023 at 13:31:59 UTC, Steven Schveighoffer
wrote:
However, I can't think of a valid reason to allow `static` on a
module-level scope. Applying static to a declaration at
module-level should be a no-op. So maybe that's one "use" of
static that can be eliminated.
Well, it can
On Thursday, 29 June 2023 at 14:18:05 UTC, kiriakov wrote:
How to create option type over std.sumtype ?
```
enum None;
struct Some(T) { T x; }
alias Option = SumType!(Some!T, None);
```
I get
Error: undefined identifier `T`
Looks like you meant to type
alias Option(T) = SumType!(Some!T,
On Saturday, 24 June 2023 at 17:00:36 UTC, Cecil Ward wrote:
I would like to use scope guards but in the guard I need to get
access to some local variables at the end of the routine. This
doesn’t really seem to make sense as to how it would work,
because their values depend on the exact point w
On Thursday, 22 June 2023 at 00:10:19 UTC, Cecil Ward wrote:
Is .reserve()’s argument scaled by the entry size after it is
supplied, that is it is quoted in elements or is it in bytes?
I’m not sure whether the runtime has a knowledge of the element
type so maybe it doesn’t know anything about s
On Sunday, 18 June 2023 at 20:24:10 UTC, Cecil Ward wrote:
On Thursday, 8 June 2023 at 05:11:04 UTC, Ali Çehreli wrote:
dmd's -makedeps command line switch should be helpful there.
(I did not use it.)
Ali
I wasn’t intending to use DMD, rather ldc if possible or GDC
because of their excell
On Sunday, 18 June 2023 at 19:05:19 UTC, rempas wrote:
On Sunday, 18 June 2023 at 18:17:16 UTC, Paul Backus wrote:
`__ctor` doesn't create a new object, it initializes an
existing object. You need to create the object first, then
call `__ctor` on it:
```d
void main() {
Test test;
test._
On Sunday, 18 June 2023 at 17:43:01 UTC, rempas wrote:
Ok, so I'm having a struct that has a constructor that takes a
template parameter. I suppose this question could also be named
`how to initialize constructors with template parameters` but
whatever! The funny thing is, I think that I may ha
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`?
I need this for my
[tiny-svg](https://github.com/rillki/tiny-svg) project to
generate `setX` methods for all Shapes.
Example:
`
On Tuesday, 30 May 2023 at 02:57:52 UTC, Cecil Ward wrote:
I have often come into difficulties where I wish to have one
routine that can be called with either immutable or (possibly)
mutable argument values. The argument(s) in question are in,
readonly, passed by value or passed by const refere
On Friday, 14 April 2023 at 14:10:41 UTC, Leonardo wrote:
Thanks. But this works only to one function per time. Is there
any way to do this to an imported library at all? something
like `@trusted import library`
No, there isn't. C is an unsafe language, so if you want to call
C from `@safe` c
On Friday, 14 April 2023 at 03:50:37 UTC, backtrack wrote:
Dear All, I am new to D lang. I have been given a task to
consume the .dll generated from a D lang project.
I added extern (c) function for call the .dll from CPP file. i
have code like below
```
// myfile.d
extern(c)
{
mystruc
1 - 100 of 882 matches
Mail list logo