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*)
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
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
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
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
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
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
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
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
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?
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
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 =
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
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)
| ^
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?
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
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
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;
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:
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
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()` 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,
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,
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
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
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
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
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
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++.
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
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
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, 12 October 2023 at 21:20:44 UTC, Jonathan M Davis
wrote:
look like?
Types can have static members.
Basically what it comes down to is that outside of immutable
data, pure functions only have access to their arguments and to
what they can access via their arguments (be it by
On Thursday, 12 October 2023 at 21:20:44 UTC, Jonathan M Davis
wrote:
Thanks Jonathan
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 Wednesday, 11 October 2023 at 12:54:53 UTC, user1234 wrote:
`extern(C)` on module level functions affect the mangling and
the calling convention.
- Mangling is used by the linker to link symbols between
objects.
- Calling convention affects the compiler backend in how code
is generated
What does the extern (c) attribute(?) do?
Does it tell the compiler/linker to build the function like a C
compiler would build a C function? If so what does that mean?
Does it tell the compiler/linker to let C functions know it
exists? If so what does that mean?
Is it meant for the compiler or
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
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:
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 */,
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
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
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()).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
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
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 Sunday, 2 July 2023 at 20:27:47 UTC, Steven Schveighoffer
wrote:
On 7/2/23 1:02 PM, Paul wrote:
[...]
Use a static foreach:
```d
import std.traits; // for FieldNameTuple. there are other ways,
but this is the most straightforward
switchlabel: // this is needed for break inside a static
I have a struct similar to the following example. I'd like to
build an adder method without having to code the whole method.
How do I use the D language to do this? Template, mixins,
CTFE..all of them?
```d
struct myS {
int a, b, c, d, e, f, g, h, i;
adder(string s, int n) {
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
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
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
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
On Thursday, 15 June 2023 at 02:21:16 UTC, Steven Schveighoffer
wrote:
Not in as short code. You could write a helper though:
```d
auto deepIn(V, K, Keys...)(V[K] aa, Keys keys) if (Keys.length
> 0)
{
auto v = keys[0] in aa;
static if(keys.length == 1)
return v;
else
return
I found I can check for key membership in a multi-D aa...
```d
byte zKey = someval;
byte[byte][byte][byte] cubelist;
foreach(byte xK, yzcubelist; cubelist) {
foreach(byte yK, zcubelist; yzcubelist) {
foreach(byte zK, val; zcubelist) {
```
with this expression...
```d
if(zKey in
On Wednesday, 14 June 2023 at 22:44:41 UTC, Ali Çehreli wrote:
By the way, the string that bitfields() generates can be
visualized by simply printing it:
const code =
bitfields!(
ubyte, "A", 1,
ubyte, "B", 1,
ubyte, "C", 1,
ubyte,
On Wednesday, 14 June 2023 at 14:43:58 UTC, Ali Çehreli wrote:
D's string mixin syntax may not be the best, the implementation
may be slower than necessary, and the concept may be strange
(not macros but very similar) but I still find phobos's
bifields to be brilliant.
I would like to have labeled bits in a union with a ubyte.
Something like this:
```d
struct MyStruct {
union {
ubyte status;
bit A, B, C…etc
}
}
```
Is something like this possible?
Thanks
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
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`
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)
{
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
On Thursday, 6 April 2023 at 16:27:23 UTC, Alex Bryan wrote:
My understanding browsing the documentation is the matchAll
returns a range of Captures (struct documented at
https://dlang.org/phobos/std_regex.html#Captures). In your for
loop I think c[0] will contain the current full match
My regex is matching but doesnt seem to be capturing. You may
recognize this from the AOC challenges.
file contains...
**Valve AA has flow rate=0; tunnels lead to valves DD, II, BB**
**Valve BB has flow rate=13; tunnels lead to valves CC, AA**
**Valve CC has flow rate=2; tunnels lead to valves
On Thursday, 6 April 2023 at 01:44:15 UTC, H. S. Teoh wrote:
D ranges are conceptually sequential, but the actual underlying
memory access patterns depends on the concrete type at runtime.
An array's elements are stored sequentially in memory, and
arrays are ranges. But a linked-list can
On Wednesday, 5 April 2023 at 23:06:54 UTC, H. S. Teoh wrote:
So your data structures and algorithms should be designed in a
way that takes advantage of linear access where possible.
T
Yes I understand, basically, what's going on in hardware. I just
wasn't sure if the access type was
On Tuesday, 4 April 2023 at 22:20:52 UTC, H. S. Teoh wrote:
Best practices for arrays in hot loops:
- Avoid appending if possible; instead, pre-allocate outside
the loop.
- Where possible, reuse existing arrays instead of discarding
old ones
and allocating new ones.
- Use slices where
On Monday, 3 April 2023 at 23:50:48 UTC, Steven Schveighoffer
wrote:
So what you need is inside `createSpansOfNoBeacons`, take as a
reference a `ref Span[MAX_SPANS]`, and have it return a
`Span[]` that is a slice of that which was "alocated".
See if this helps.
Well Steven just making the
On Monday, 3 April 2023 at 23:13:58 UTC, Steven Schveighoffer
wrote:
Yeah, please post.
```d
module aoc2215b2;
import std.stdio;
import std.file: readText;
import std.conv: to;
import std.math: abs;
import std.traits;
import std.parallelism;
import std.range;
import core.time: MonoTime;
//
On Monday, 3 April 2023 at 22:24:18 UTC, Steven Schveighoffer
wrote:
If your `foreach` body takes a global lock (like
`writeln(i);`), then it's not going to run any faster
(probably slower actually).
**Ok I did have some debug writelns I commented out.**
And did it help?
**No**
My
On Sunday, 2 April 2023 at 15:32:05 UTC, Steven Schveighoffer
wrote:
It's important to note that parallel doesn't iterate the range
in parallel, it just runs the body in parallel limited by your
CPU count.
**?!?**
If your `foreach` body takes a global lock (like
`writeln(i);`), then it's
On Saturday, 1 April 2023 at 18:30:32 UTC, Steven Schveighoffer
wrote:
On 4/1/23 2:25 PM, Paul wrote:
```d
import std.range;
foreach(; iota(0, 2_000_000).parallel)
```
-Steve
Is there a way to tell if the parallelism actually divided up the
work? Both versions of my program run
```d
import std.range;
foreach(; iota(0, 2_000_000).parallel)
```
-Steve
Is there a way to verify that it split up the work in to
tasks/threads ...? The example you gave me works...compiles w/o
errors but the execution time is the same as the non-parallel
version. They both take about 6
Thanks Steve.
Thanks in advance for any assistance.
As the subject line suggests can I do something like? :
```d
foreach (i; taskPool.parallel(0..2_000_000))
```
Obviously this exact syntax doesn't work but I think it expresses
the gist of my challenge.
Thanks in advance for any assistance.
As the subject line states I'm just now trying to learn
profiling. I have a very small program with 1/2 dozen functions
and would like to see where the cpu is spending the most time.
I've tried both of these lines with identical results:
**ldc2
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
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 Monday, 20 March 2023 at 17:47:19 UTC, Adam D Ruppe wrote:
On Monday, 20 March 2023 at 17:42:17 UTC, Paul wrote:
Do we have some such function in our std library?
Try
static import std.file;
string s = std.file.readText("filename.txt");
http://phobos.dpldocs.info/std.file.rea
I've been looking through our Library documentation and having
trouble finding what I want. **I'd like to read a text file in
all at once** and do some searching and analytics on it instead
of reading it bit by bit or line by line. Do we have some such
function in our std library?
Thanks
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
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
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
1 - 100 of 1162 matches
Mail list logo