On Tuesday, 4 October 2022 at 00:38:25 UTC, Ali Çehreli wrote:
Good catch but I think what we want is a copy of the front
element, at least for InputRanges (.save does not work for
File.byLine :/).
What is the generic way of copying an element? I wonder whether
we have to use isSomeString to
On Wednesday, 19 October 2022 at 01:49:26 UTC, mw wrote:
On Wednesday, 19 October 2022 at 01:38:27 UTC, Adam D Ruppe
wrote:
On Wednesday, 19 October 2022 at 01:34:54 UTC, mw wrote:
Is there any (design) doc about this?
scroll up, click the link from this very thread.
https://github.com/dlang
On Saturday, 22 October 2022 at 15:21:07 UTC, Kevin Bailey wrote:
OTOH, a forward iterator (i.e. copyable but does not need to
go backwards) solves the problem elegantly and efficiently.
The builtin function [`byKeyValue`][1] returns a forward range
(D's version of a forward iterator) over the
On Saturday, 22 October 2022 at 21:53:05 UTC, WhatMeWorry wrote:
string[] tokens = userSID.output.split!isWhite;
writeln("tokens = ", tokens);
[...]
Is there a clever way that I can discard all the extra null
strings in the resultant string array?
Easiest way is to use [`filter`][1]. Here'
On Sunday, 23 October 2022 at 13:32:44 UTC, matheus wrote:
I have a design question and I'd like to hear some advice.
Let's say that I want to create a method to sort an array:
arr.sort(asc);
I think usually this would usually return a new set of that
array but now sorted.
But If I want
On Tuesday, 25 October 2022 at 16:52:48 UTC, Salih Dincer wrote:
On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov
wrote:
Does the second piece of code shows a bug or my expectation is
not correct (and why if so)?
This is a bug:
```d
void main()
{
struct B
{
struct A
{
On Tuesday, 25 October 2022 at 17:54:16 UTC, Salih Dincer wrote:
On Tuesday, 25 October 2022 at 17:18:35 UTC, Paul Backus wrote:
It's not a bug. They're pointing to the exact same instance of
`A` in memory:
I don't understand? So I don't understand why it causes
problems with dynamic arrays!
On Tuesday, 25 October 2022 at 20:27:18 UTC, Ali Çehreli wrote:
On 10/25/22 13:12, Paul Backus wrote:
> In order to create a copy of a static array
Although .dup works for static arrays as well, you meant
"dynamic array" and everyones knows it. :)
Yes; thank you for the correction. :)
On Tuesday, 1 November 2022 at 23:01:57 UTC, Per Nordlöw wrote:
When is it preferrable to use
```d
struct S { private T t; alias t this; }
```
instead of
```d
struct S { public T t; alias t this; }
```
for any given type `T`?
If the `alias this` needs to work outside the module where `S` is
On Thursday, 3 November 2022 at 10:00:27 UTC, Bruno Pagis wrote:
Good morning,
I have the following class:
```
class A {
int[] array;
...
void print() {
writeln("array = ", this.array);
}
}
```
I would like to unit test the print function (yes, I know, not
very useful on the abov
On Thursday, 3 November 2022 at 06:26:22 UTC, Salih Dincer wrote:
Hi All,
Isn't there a save feature for `iota()`?
Looking at the source, it seems that only the numeric overloads
of `iota` implement `save`. I think this is probably just an
oversight, though, since I can't see any reason why
On Saturday, 5 November 2022 at 16:13:18 UTC, 0xEAB wrote:
Apparently there a difference between:
- ```d
Message withBody(Body body_) return scope { /* … */ }
```
- ```d
Message withBody(Body body_) scope return { /* … */ }
```
```
Deprecation: returning `this._body` escapes a referen
On Thursday, 10 November 2022 at 17:04:31 UTC, mw wrote:
Hi,
Anyone can help explain what is the difference between
x.atomicOp!"+="(1) and atomicFetchAdd(x, 1)?
Looking at the source in druntime, `atomicOp!"+="` forwards to
`atomicFetchAdd` internally, so they should have the same
behavior.
On Tuesday, 15 November 2022 at 13:01:39 UTC, Siarhei Siamashka
wrote:
Well, there's another way to look at it:
https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
('Unsafe Rust exists because, by nature, static analysis is
conservative. When the compiler tries to determine whether or
not
On Tuesday, 15 November 2022 at 14:05:42 UTC, Siarhei Siamashka
wrote:
On Tuesday, 15 November 2022 at 13:16:18 UTC, Paul Backus wrote:
D's safety model is the same. In `@safe` code, D will reject
anything that the compiler cannot say for sure is memory safe.
However, unlike in Rust, `@safe` is
On Saturday, 19 November 2022 at 14:07:59 UTC, Nick Treleaven
wrote:
Hi,
The following seems like a bug to me (reduced code, FILE*
changed to int*):
```d
@safe:
struct LockedFile
{
private int* fps;
auto fp() return scope => fps;
}
void main()
{
int* p;
{
auto lf = Lo
On Thursday, 17 November 2022 at 22:05:45 UTC, jwatson-CO-edu
wrote:
* Compatibility with both Windows and Linux. What do I need to
consider?
- Can I create threads/processes under Windows?
[core.thread][1] and [std.process][2] provide
platform-independent interfaces for this that should wo
On Friday, 25 November 2022 at 14:07:28 UTC, ShadoLight wrote:
On Saturday, 19 November 2022 at 15:00:16 UTC, Paul Backus
wrote:
Since, in your example, `lf` has global lifetime, the compiler
deduces that `lf.fp` also has global lifetime, and therefore
there is nothing wrong with assigning it t
On Monday, 28 November 2022 at 20:58:43 UTC, Per Nordlöw wrote:
For which types `T` does
```d
__traits(isCopyable, T)
```
differ from
```d
__traits(isPOD, T)
```
?
Lots of types. For example, types with copy constructors or
destructors are not POD but may still be copyable.
This should b
On Monday, 28 November 2022 at 23:11:37 UTC, Per Nordlöw wrote:
the real question I had is whether one should use `isPOD`
instead of `isCopyable` in cases
```d
static if (__traits(isCopyable, Element))
insertAt(element, index);
else
insert
On Tuesday, 29 November 2022 at 18:59:46 UTC, DLearner wrote:
To me, it appears that there are really two (_entirely
separate_) concepts:
A. Supporting the useful concept of variable length (but
otherwise entirely conventional) arrays;
B. Supporting a language feature that acts as a window to
On Saturday, 3 December 2022 at 22:46:31 UTC, DLearner wrote:
I agree should not change existing meaning of
```
int[] A;
```
But why not allow a construct for value-type variable arrays
like:
```
int[*] B;
```
There's no reason to add more complexity to the language for this
when the same r
On Tuesday, 20 December 2022 at 20:01:04 UTC, Anonymouse wrote:
What does `-allinst` even do
`-allinst` tells the compiler to generate code for all
instantiated templates, even if it thinks that code has already
been generated in a different object file.
Why would the compiler think that? S
On Thursday, 22 December 2022 at 16:23:16 UTC, jwatson-CO-edu
wrote:
I am confused about why Program 1 produces random output but
Program 2 does not.
The code you have posted as "Program 2" is incomplete, and cannot
be compiled as-is. I have made some changes in order to get it to
compile and
On Monday, 2 January 2023 at 22:53:13 UTC, Charles Hixson wrote:
I want to return values of the template parameter type, so
there doesn't seem to be any way to dup or idup them.
It's hard to say where exactly you're going wrong if you only
post the error message, without the code that produced
On Monday, 2 January 2023 at 23:25:48 UTC, Charles Hixson wrote:
They syntax I wanted was something like:
bool func (const out Key k, const out Val v) { k =
this.key.dup; v = this.val.dup; return true; }
This works for me:
import std.typecons;
auto func(Key, Value)(Key k, Value
On Sunday, 15 January 2023 at 12:26:15 UTC, thebluepandabear
wrote:
If I have the following code:
```D
class X {
private int num;
struct Y {
// how to access num?
}
}
```
How would I access `num` from `Y`?
Whenever I try to I get a compilation error.
I believe that it's p
On Tuesday, 31 January 2023 at 01:04:41 UTC, Paul wrote:
Greetings,
for an array byte[3][3] myArr, I can code myArr[0] = 5 and have:
5,5,5
0,0,0
0,0,0
Can I perform a similar assignment to the column? This,
myArr[][0] = 5, doesn't work.
Thanks!
Here's a solution using standard-library fun
On Friday, 10 February 2023 at 22:10:20 UTC, Ben Jones wrote:
I'm trying to write a range adaptor for linked list types. The
range type seems to work OK, but my helper function to deduce
the node type has a compiler error. My hunch is that
`nextField` loses its association with T when I'm try
On Wednesday, 22 February 2023 at 20:20:46 UTC, Dark Hole wrote:
```d
template Foo(T, alias T[] Array) {
// ...
}
// ...
Bar[] arr;
Foo!(Bar, arr);
```
This is valid D, but it doesn't work. It gives error "Error:
template instance `Foo!(Bar, arr)` does not match template
declaration `Foo(T
On Friday, 24 February 2023 at 14:22:17 UTC, user1234 wrote:
you can break using `goto`, restore `static` everywhere, and
using local introspection determine whether the result exists.
```d
struct Bar
{
@("hello") int t;
}
static bool hasAttribute(alias F, T)()
{
static foreach
On Sunday, 26 February 2023 at 02:33:21 UTC, guacs wrote:
NOTE: The error is happening when I'm using the SumType and I
suspect that I'm using it incorrectly.
I am not sure whether this is the specific error that is causing
your problem, but there is a mistake in your use of `SumType` in
`ex
On Sunday, 26 February 2023 at 14:17:50 UTC, ryuukk_ wrote:
On Sunday, 26 February 2023 at 07:11:55 UTC, Paul Backus wrote:
Since `Expression` contains `Binary` and `Unary`, and `Binary`
and `Unary` contain `Expression`, that means `Expression`
contains itself--which is not allowed, because it
On Wednesday, 1 March 2023 at 19:05:10 UTC, DLearner wrote:
(1) & (2) compile and run with the expected results.
But (3) fails with:
```
Error: variable `wk_Idx` is shadowing variable
`for3.main.wk_Idx`
```
Why is this usage wrong?
With `foreach`, you can't reuse an existing variable as the l
On Sunday, 12 March 2023 at 15:31:07 UTC, Salih Dincer wrote:
Moreover, `auto ref` or `ref auto` is needed in functions.
That's because `ref` isn't part of the argument or return value's
type, so it isn't covered by **type** inference. Instead, D has a
totally separate feature for "`ref` infe
On Tuesday, 14 March 2023 at 05:47:35 UTC, Jeremy wrote:
Hi, in C and C++ you can use #define to substitute a value in
place of an identifier while preprocessing. If you initialize a
new string and don't change its value after that, will the
compiler substitute the string identifier with its va
On Tuesday, 14 March 2023 at 08:21:00 UTC, amarillion wrote:
I'm trying to understand why this doesn't work. I don't really
understand the error. If I interpret this correctly, it's
missing a length attribute on a string, but shouldn't length be
there?
By default, D's standard library treats
On Tuesday, 14 March 2023 at 10:19:24 UTC, Elfstone wrote:
I went back to some of my old code and couldn't stand what I
had ended up with - If I already have a well-defined `Vector`,
why do I have to write extra code to implement `isVector`, and
use `isVector` instead of simply declaring the pa
On Wednesday, 15 March 2023 at 16:40:52 UTC, bomat wrote:
Just out of curiosity:
Can you explain to me why this is called an `enum` although
it's clearly not an enumeration?
Seems like a random abuse of a keyword...
It's shorthand for defining an unnamed `enum` with a single
member:
```d
e
On Wednesday, 29 March 2023 at 20:50:04 UTC, Steven Schveighoffer
wrote:
On 3/29/23 4:29 PM, ag0aep6g wrote:
But regardless of Salih's exact intent, the broader point is:
a non-ref overload could be added to Phobos. And that would
enable `a[1..$-1].phobos_put([2, 3])`. Which is what he asked
On Friday, 31 March 2023 at 02:23:29 UTC, Steven Schveighoffer
wrote:
There's a certain attempt in phobos in some places to try and
ensure code that is going to confuse will not compile. I think
this is one of those attempts.
Consider that if you pass a slice into `put`, then it returns
nothi
On Thursday, 13 April 2023 at 07:05:10 UTC, Chris Katko wrote:
Right now, I'm using pointers which resolves to:
```D
// float* opIndex(string key){...} using pointer
(*s["tacos"])++; // works with pointer, but is strange looking
s["tacos"]++; // preferred syntax or something similar
```
You 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
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 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 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 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 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 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 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 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, 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 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, 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 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 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, 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 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, 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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, 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 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
101 - 200 of 853 matches
Mail list logo