On Friday, 30 September 2022 at 15:57:22 UTC, Quirin Schroll
wrote:
When I do `new void[](n)`, is that buffer allocated with an
alignment of 1 or what are the guarantees?
It is guaranteed an alignment of at least 1 because `void.alignof
== 1` (and because that is the lowest possible integer
a
On Saturday, 1 October 2022 at 00:32:28 UTC, tsbockman wrote:
alias Chunk = AliasSeq!(ubyte, ushort, uint, ulong,
Chunk16)[shift];
Oops, I forgot that `ulong.alignof` is platform dependent. It's
probably best to just go ahead and explicitly specify the
alignment for all `Chunk` ty
On Saturday, 1 October 2022 at 01:37:00 UTC, Steven Schveighoffer
wrote:
On 9/30/22 11:57 AM, Quirin Schroll wrote:
Also, is the alignment of any type guaranteed to be a power of
2?
In practice, it's not necessarily a power of 2, but it's *at
least* 16 bytes.
**Types** always require some p
On Friday, 30 September 2022 at 13:11:56 UTC, christian.koestlin
wrote:
Dear Dlang experts,
up until now I was perfectly happy with implementing
`(override) string toString() const` or something to get nicely
formatted (mostly debug) output for my structs, classes and
exceptions.
Human bein
On Saturday, 1 October 2022 at 10:02:34 UTC, Salih Dincer wrote:
On Saturday, 1 October 2022 at 08:26:43 UTC, tsbockman wrote:
`StringBuilder` is a utility shared across the entire project:
Appender not good enough; at least in terms of allocating
memory and accumulating a string?
`Appender
On Sunday, 2 October 2022 at 23:45:45 UTC, drug007 wrote:
It works but not as someone could expect. In case of
```D
Foo[2] arr = void;
```
`arr` value is not defined, it is not an initialized array of
uninitialized elements like you want, it is just uninitialized
array.
This is incorrect. It
On Sunday, 2 October 2022 at 23:30:16 UTC, ryuukk_ wrote:
```D
MyStruct test = void;
```
Does this guarantee that the compiler will not initialize it?
It's more of a request, than a guarantee. For example, `= void`
may be ignored for the fields of `struct`s and `class`es:
```D
struct ABC {
On Saturday, 8 October 2022 at 23:06:13 UTC, Anonymouse wrote:
I have some nested templated code that takes function pointers.
In many cases I pass it functions of identical signatures,
except some are `@safe` and others are `@system`. In those
cases the templates end up getting instantiated tw
On Thursday, 5 January 2023 at 11:55:33 UTC, thebluepandabear
wrote:
```D
foreach (BoardSize boardSize; arr) {
Button button = new Button();
button.text = format("%sx%s", boardSize[0], boardSize[1]);
button.onButtonClick = {
eventHandler.settingsWindow_onBoardSizeButtonClick(
On Thursday, 5 January 2023 at 13:05:46 UTC, thebluepandabear
wrote:
Update some time later: the only way (oof!) around this seems
to be using a `static foreach` with arrays:
```D
Button[3] b;
static foreach (indx, BoardSize boardSize; arr) {
b[indx] = new Button();
b[indx].text = form
On Thursday, 5 January 2023 at 09:10:00 UTC, areYouSureAboutThat
wrote:
My question is: why is there no bounds checking occurring if I
forget to use -betterC?
module test;
extern(C) void main()
Note that whether bounds checking is performed depends on
[compiler
switches](https://dlang.org/
On Friday, 17 April 2020 at 21:25:34 UTC, kdevel wrote:
On Friday, 17 April 2020 at 12:59:20 UTC, Simen Kjærås wrote:
A curiosity. Usually you cast into the type on the left. But
Checked!(short, Throw) b = cast (Checked!(short, Throw)) a;
does not compile:
Error: template std.experimenta
On Friday, 17 April 2020 at 21:25:34 UTC, kdevel wrote:
A curiosity. Usually you cast into the type on the left. But
Checked!(short, Throw) b = cast (Checked!(short, Throw)) a;
does not compile:
Error: template std.experimental.checkedint.Checked!(int,
Throw).Checked.opCast cannot ded
On Saturday, 18 April 2020 at 15:20:42 UTC, kdevel wrote:
On Saturday, 18 April 2020 at 08:39:52 UTC, tsbockman wrote:
https://code.dlang.org/packages/checkedint
Hm.
$ dub test
Generating test runner configuration 'checkedint-test-library'
for 'library' (library).
Excluding package.d fil
On Saturday, 18 April 2020 at 15:20:42 UTC, kdevel wrote:
On Saturday, 18 April 2020 at 08:39:52 UTC, tsbockman wrote:
https://code.dlang.org/packages/checkedint
Hm.
$ dub test
Generating test runner configuration 'checkedint-test-library'
for 'library' (library).
Excluding package.d fil
On Tuesday, 21 April 2020 at 16:03:20 UTC, Russel Winder wrote:
then which of these is the right way of accessing the value?
cast(ubyte)ZoneNumber.One
to!ubyte(ZoneNumber.One)
Either is acceptable because there is no way that this operation
can fail. Using a naked `cast` makes less work for t
On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote:
There is a Python eval() equivalent in Dlang working in Runtime?
No, and there almost certainly never will be due to fundamental
differences between the languages. Depending on your goal, the
closest alternatives are using the string m
On Friday, 1 May 2020 at 18:07:54 UTC, H. S. Teoh wrote:
On Fri, May 01, 2020 at 05:44:27PM +, tsbockman via
Digitalmars-d-learn wrote:
On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote:
> There is a Python eval() equivalent in Dlang working in
> Runtime?
No, and there
On Tuesday, 30 June 2020 at 16:36:45 UTC, H. S. Teoh wrote:
And on that note, this implicit static -> dynamic array
conversion is seriously a nasty misfeature that ought to be
killed with fire. It leads to bugs like this:
struct Database {
int[] data;
vo
On Wednesday, 1 July 2020 at 20:05:51 UTC, tsbockman wrote:
If you want the compiler to stop you from accidentally keeping
references to stack variables past the end of their scope, you
need to annotate your functions @safe and compile with
-preview=dip1000: https://run.dlang.io/is/3VdDaN
Fur
I want to do this:
import core.thread.osthread : Thread;
void main() {
shared(Thread) thread1 = new Thread({
// Do stuff for a while...
});
auto thread2 = new Thread({
// ...
if(thread1.isRunning)
// Do a thing.
else
// Do a differe
On Saturday, 5 December 2020 at 18:58:13 UTC, Adam D. Ruppe wrote:
On Saturday, 5 December 2020 at 18:48:19 UTC, tsbockman wrote:
(The documentation for core.thread is broken right now, with
dead links and at least one reference to an example that
doesn't actually appear anywhere on the page.)
On Saturday, 5 December 2020 at 19:51:14 UTC, Jack wrote:
version(Windows) extern(C) export
struct C_ProcessResult
{
wchar*[] output;
In D, `T[]` (where T is some element type, `wchar*` in this case)
is a slice structure that bundles a length and a pointer
together. It is NOT the same
On Saturday, 5 December 2020 at 21:55:13 UTC, Jack wrote:
my code now look like this, still there's a memory corrupt.
Could anyone help point out where is it?
...
foreach(i; 0..output.length) {
wstring ws;
transcode(output[i], ws);
auto s = malloc(ws.length + 1);
if(!s) {
On Sunday, 6 December 2020 at 02:07:10 UTC, Jack wrote:
On Saturday, 5 December 2020 at 23:31:31 UTC, tsbockman wrote:
On Saturday, 5 December 2020 at 21:55:13 UTC, Jack wrote:
wstring ws;
transcode(output[i], ws);
auto s = malloc(ws.length + 1);
if(!s) {
onOutOfMemoryEr
On Monday, 4 January 2021 at 02:17:33 UTC, bdh wrote:
I'm pretty sure it's correct?
Here's the D version:
https://repo.or.cz/magickd.git/blob/e5d06e939:/source/magickd/core/c/image.d#l751
Here's the C version:
http://hg.code.sf.net/p/graphicsmagick/code/file/a622095da492/magick/image.h#l
On Friday, 8 January 2021 at 20:43:37 UTC, Andrey wrote:
Hello,
struct Value
{
int value;
string data;
string[] text;
}
void test(const ref Value value)
{
Value other = void;
other.text = value.text;
}
void main()
{
Value row;
row.value = 10;
row.data = "gg
On Friday, 8 January 2021 at 23:10:13 UTC, tsbockman wrote:
5) Tell the compiler that `other.text` may be used to
mutate `row.text` by `const` from the `value` parameter of
`test`. Do not do this unless that's really what you want!
Oops, that should say:
5) Tell the compiler that `oth
On Saturday, 9 January 2021 at 02:07:50 UTC, Ali Çehreli wrote:
The destination is immutable(char)[].
No, it's not. string[] means immutable(char)[][] - note the
second set of brackets.
Even though the source is 'const ref', other.text is a copy of
the slice object (the pointer and the leng
On Monday, 11 January 2021 at 00:43:00 UTC, Tim wrote:
When MessageService calls the delegate for start, db is null.
If I call start() in the Foo constructor it works just fine. Am
I missing something here? Do delegates get called outside of
their class context? I know I could just pass the db
On Tuesday, 12 January 2021 at 14:00:11 UTC, Steven Schveighoffer
wrote:
On 1/11/21 8:49 PM, tsbockman wrote:
However, this re-ordering IS permitted to freely alter the
behavior of your code from the perspective of OTHER threads. A
likely cause of your bug is that the write to db by the
constr
On Wednesday, 13 January 2021 at 02:15:49 UTC, Tim wrote:
Basically, the program calls a function which modifies a
document in the database. If it is called form it's own class'
constructor, it works fine. If it is called by a thread, it
never returns.
...
class Caller : Thread{
void deleg
On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote:
I've always heard programmers complain about Garbage Collector
GC. But I never understood why they complain. What's bad about
GC?
SHORT VERSION: While garbage collection is great for many
applications, GC also has some significant
On Wednesday, 13 January 2021 at 11:50:26 UTC, Andrey wrote:
Today is 2021. Dlang still doesn't have ctfe write functions?
You make it sound like D is behind the times. Is CTFE I/O a
standard feature in other languages? How many other languages
even have a CTFE feature comparable to D's?
On Wednesday, 13 January 2021 at 21:56:58 UTC, mw wrote:
I think this flexibility to mix GC & manual memory management
is very unique in D. Actually I'm not sure if it can be done in
other languages at all.
Yes, this is one of the great things about D.
There are miscellaneous problems with th
On Wednesday, 13 January 2021 at 23:38:54 UTC, oddp wrote:
Just two langs I use from time to time:
1) nim via forced ctfe; way faster than d by running through a
vm:
const foo = fib(42)
static:
echo "foobar"
2) crystal via macros:
{{ puts "foobar" }}
Another one would be zig via comptime
On Friday, 15 January 2021 at 12:39:30 UTC, MGW wrote:
GC cleans memory using the FIFO paradigm. Is it possible to
switch GC to work using the LIFO paradigm?
As others already said, the current GC isn't FIFO; it just scans
everything once in a while a frees whatever it can, new or old.
Howev
On Thursday, 21 January 2021 at 14:00:28 UTC, cerjones wrote:
I'm a bit unsure if this is reasonable or not.
Thoughts?
Signed indexes are fine, if there is a principled reason to use
them. Just make sure that you are consistent by making `length`,
`opDollar`, etc. use signed types, as well.
On Thursday, 21 January 2021 at 05:20:27 UTC, frame wrote:
I was not asking here to re-produce my code or debug since it
cannot provide a snippet if I do not know what could cause the
error.
Generally, I don't need to know what causes an error in order to
produce an MCVE. I have successfully
On Friday, 22 January 2021 at 00:59:32 UTC, tsbockman wrote:
2) Remove, simplify, or mock up/stub out (like for unit tests)
some large chunk of the remaining code in the program, from a
part of the program that I *think* is unrelated to the error.
3) Re-test the program.
a) If the failure g
On Friday, 22 January 2021 at 02:18:11 UTC, frame wrote:
Anyway. It was a simple question not a prove that there is a
bug in the compiler.
isCallable is intended to either evaluate to a boolean, or give a
clear compile-time error message. Since it did neither of those
things for you, I suspec
On Friday, 22 January 2021 at 03:08:23 UTC, frame wrote:
It's like asking your mechanican if he can guess what's causing
the weird sound in the car and he replies with: why didn't you
disassemble your car already?
Cars are mass-produced copies of a relatively small number of
rather similar de
On Saturday, 23 January 2021 at 05:54:09 UTC, Виталий Фадеев
wrote:
auto listFactory( T )( T data )
{
return new List!( T )( data );
}
This is the correct way to do it in D; it's annoying, I know.
(Personally, I usually shorten `listFactory` to just `list` to
make the nam
On Wednesday, 27 January 2021 at 18:09:39 UTC, frame wrote:
there must be multiple instances of GCs running because
Sharing data between multiple threads that each use a different
instance of the D GC will definitely not work right, because each
GC will only know to pause the threads and scan
On Wednesday, 27 January 2021 at 18:09:39 UTC, frame wrote:
I have no idea if there are multiple runtimes. I just use the
mixin SimpleDllMain. But there must be multiple instances of
GCs running because
Another thread is running right now which I think is touching
upon these same issues. Adam
On Sunday, 24 January 2021 at 03:59:26 UTC, Ali Çehreli wrote:
I am surprised how much I had learned at that time and how much
I've already forgotten. :/ For example, my PR involves
thread_setThis, which seems to be history now:
https://docarchives.dlang.io/v2.068.0/phobos/core_thread.html#.t
On Thursday, 28 January 2021 at 00:58:17 UTC, rikki cattermole
wrote:
On 28/01/2021 1:16 PM, tsbockman wrote:
The documentation build on dlang.org is broken. Check the
source code or Adam D. Ruppe's dpldocs.info for the complete
documentation:
http://dpldocs.info/experimental-docs/core.thread.
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster
wrote:
Here is the output/input of the program:
Type in data for an egg:
Width: 3
Hight: 2
object.Error@(0): Integer Divide by Zero
...
Here is the source code:
import std.stdio;
import std.string;
void main(){
egg[1000] data
On Thursday, 28 January 2021 at 07:50:43 UTC, frame wrote:
Under Linux everything is shared. Under Windows each DLL seems
to run in its own thread, has its own rt_options and do not see
any __gshared variable value. Its completely isolated and so I
assume that also GC is.
This stuff works cor
On Thursday, 28 January 2021 at 20:17:09 UTC, frame wrote:
On Thursday, 28 January 2021 at 19:22:16 UTC, tsbockman wrote:
It is possible to get things sort of working with on Windows,
anyway.
I'm ok with it as long as the memory is not re-used by the GC.
It seems that it can be prevented with
On Thursday, 4 February 2021 at 08:16:06 UTC, Saurabh Das wrote:
This code:
void main()
{
import std.typecons : rebindable, tuple;
const c = new C();
auto t = tuple(c.rebindable);
}
class C
{
}
When compiled with DMD 2.095.0 gives a warning:
Warning: struct Rebindable has method t
On Friday, 12 February 2021 at 01:23:14 UTC, Josh wrote:
I'm trying to read in a text file that has many duplicated
lines and output a file with all the duplicates removed. By the
end of this code snippet, the memory usage is ~5x the size of
the infile (which can be multiple GB each), and when
On Wednesday, 17 February 2021 at 04:10:24 UTC, tsbockman wrote:
On files small enough to fit in RAM, it is similar in speed to
the other solutions posted, but less memory hungry. Memory
consumption in this case is around (sourceFile.length + 32 *
lineCount * 3 / 2) bytes. Run time is similar t
On Wednesday, 17 February 2021 at 17:45:01 UTC, H. S. Teoh wrote:
I.e., the following is NOT a good idea:
struct S {
void delegate() member;
this() {
member = &this.impl;
}
private void impl();
On Wednesday, 17 February 2021 at 20:18:53 UTC, Paul Backus wrote:
On Wednesday, 17 February 2021 at 19:42:00 UTC, tsbockman wrote:
A copy constructor and opAssign can be used to update pointers
that are relative to &this:
https://dlang.org/spec/struct.html#struct-copy-constructor
Unfortu
On Thursday, 18 February 2021 at 08:29:48 UTC, kinke wrote:
Nope, Paul is right, the copy ctors don't solve anything in
this regard. Simplest example I could come up with:
https://run.dlang.io/is/TgxyU3
I found that example very confusing, as it does not contain an
explicit copy constructor,
How can I get the alignment of a class instance? I know how to
get the size:
__traits(classInstanceSize, T)
But, there doesn't appear to be any equivalent trait for the
alignment.
(Knowing the alignment of a class instance is required to
correctly use core.lifetime.emplace, or do any sort
On Saturday, 20 February 2021 at 05:44:33 UTC, kinke wrote:
There's
https://github.com/dlang/druntime/blob/728f1d9c3b7a37eba4d59ee2637fb924053cba6d/src/core/internal/traits.d#L261.
Thanks! That's helpful.
But AFAIK, the GC only guarantees an alignment of 16 and
doesn't respect any overaligned
On Friday, 19 February 2021 at 00:13:19 UTC, Jon Degenhardt wrote:
On Wednesday, 17 February 2021 at 04:10:24 UTC, tsbockman wrote:
I spent some time experimenting with this problem, and here is
the best solution I found, assuming that perfect
de-duplication is required. (I'll put the code up o
On Monday, 22 February 2021 at 02:23:27 UTC, Steven Schveighoffer
wrote:
Hm... but does TypeInfo detail alignment? If so, we can make
this work anyway, just bump up the size needed to a power-of-2
pool.
It doesn't even need to be a power-of-2, assuming the pools
themselves are properly aligne
On Tuesday, 23 February 2021 at 03:53:00 UTC, tsbockman wrote:
size_t alignedSize(size_t typeSize, size_t typeAlignment) pure
@safe nothrow @nogc {
version(assert) {
import core.bitop : bsr;
assert(typeAlignment == (size_t(1) <<
bsr(typeAlignment)));
}
size_t ret =
On Thursday, 25 February 2021 at 11:28:14 UTC, z wrote:
Is there any way to guarantee that "packed" versions of SIMD
instructions will be used?(e.g. vmulps, vsqrtps, etc...)
To give some context, this is a sample of one of the functions
that could benefit from better SIMD usage :
float euclidea
On Thursday, 25 February 2021 at 11:28:14 UTC, z wrote:
float euclideanDistanceFixedSizeArray(float[3] a, float[3] b) {
Use __vector(float[4]), not float[3].
float distance;
The default value for float is float.nan. You need to explicitly
initialize it to 0.0f or something if you want th
On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote:
If you know when you can deallocate something, that means you
don't need the GC to collect it, so you could just allocate it
on the malloc heap instead, and call destroy/free once you're
done. You could use the C version of malloc/free
On Friday, 5 March 2021 at 21:17:24 UTC, tsbockman wrote:
On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote:
class C {...}
import core.memory : GC;
C c = cast(C) GC.malloc(C.sizeof);
...
...
import core.memory : GC;
C c = cast(C) GC.malloc(C.siz
On Sunday, 7 March 2021 at 13:26:37 UTC, z wrote:
On Thursday, 25 February 2021 at 11:28:14 UTC, z wrote:
However, AVX512 support seems limited to being able to use the
16 other YMM registers, rather than using the same code
template but changed to use ZMM registers and double the
offsets to t
On Sunday, 7 March 2021 at 18:00:57 UTC, z wrote:
On Friday, 26 February 2021 at 03:57:12 UTC, tsbockman wrote:
static foreach(size_t i; 0 .. 3/+typeof(a).length+/){
distance += a[i].abs;//abs required by the caller
(a * a) above is always positive for real numbers. You don't
need the
On Sunday, 7 March 2021 at 22:54:32 UTC, tsbockman wrote:
import std.meta : Repeat;
void euclideanDistanceFixedSizeArray(V)(ref Repeat!(3,
const(V)) a, ref Repeat!(3, const(V)) b, out V result)
if(is(V : __vector(float[length]), size_t length))
...
Resulting asm with is(V == __vector(float
On Sunday, 7 March 2021 at 22:54:32 UTC, tsbockman wrote:
...
result = diffSq[0];
static foreach(i; 0 .. 3)
result += diffSq[i];
...
Oops, that's supposed to say `i; 1 .. 3`. Fixed:
import std.meta : Repeat;
void euclideanDistanceFixedSizeArray(V)(ref Repeat!(3, const(V))
a, r
On Friday, 12 March 2021 at 17:37:43 UTC, David Zhang wrote:
I want to store interfaces as untyped void[], then cast them
back to the interface at a later time.
Assuming these interfaces are actual D `interface`s, declared
with the keyword and using the default `extern(D)` linkage,
you're wa
On Friday, 12 March 2021 at 18:50:26 UTC, tsbockman wrote:
/* This will return `null` if the value isn't really a
reference to an instance
of a subtype of `I`, or if the key isn't in the map yet. If
you don't care
about the latter case, it can be shortened to just `cast(I)
map[I.str
On Friday, 12 March 2021 at 19:24:17 UTC, David Zhang wrote:
On Friday, 12 March 2021 at 18:50:26 UTC, tsbockman wrote:
The idea is to implement a service locator s.t. code like this
is possible:
...
I don't really need to copy or move the class instances here,
just be able to read, assig
On Saturday, 13 March 2021 at 00:36:37 UTC, David Zhang wrote:
On Friday, 12 March 2021 at 22:18:59 UTC, tsbockman wrote:
You can use TypeInfo references as the keys for the struct
types, too. It's better than hashes because the TypeInfo is
already being generated anyway, and is guaranteed to
On Saturday, 13 March 2021 at 15:44:53 UTC, frame wrote:
Maybe I don't get this right but why you don't just use the
void[] as it is?
void[] mem = [i];
//...
return (cast(T[]) mem)[0];
This is how I exchange variable data between DLLs.
That works, and is more elegant than the OP's solution.
Suppose I have a templated struct member function for which I can
compute at compile-time when the function is memory safe, and
when it is not. But, the compiler cannot correctly determine this
automatically.
What is the best way to express this in code? Other than
straight-up duplicating the
On Friday, 2 April 2021 at 00:03:32 UTC, Paul Backus wrote:
On Thursday, 1 April 2021 at 22:35:01 UTC, tsbockman wrote:
Is there a better way?
Here's a technique I've used:
...
As long as the compile-time check is correct, this is sound:
the @trusted lambda can be called from @safe code if an
On Friday, 2 April 2021 at 12:47:35 UTC, z wrote:
Even if the function is changed to only accept `shared`
parameters, `.reserve` does not appear to support `shared` so
the function is impossible to use without somehow changing its
type or using `__gshared`.
There is no way that `.reserve` can
On Friday, 2 April 2021 at 19:49:30 UTC, ikod wrote:
On Thursday, 1 April 2021 at 22:35:01 UTC, tsbockman wrote:
Suppose I have a templated struct member function for which I
can compute at compile-time when the function is memory safe,
and when it is not. But, the compiler cannot correctly
de
On Sunday, 4 April 2021 at 16:38:10 UTC, frame wrote:
On Saturday, 3 April 2021 at 13:46:17 UTC, kdevel wrote:
Why does this code
ec.opAssign (bar (1)); // okay
// ec = bar (1); // Error: expression bar(1) is void and has
no value
compile with the abovementioned error?
You cannot a
On Monday, 5 April 2021 at 15:05:24 UTC, kdevel wrote:
You changed the definition of ``bar`` while the exception
collector (``EC``) is meant to catch and collect an exception
thrown from the *unmodified* function.
My point was that the code will work if you do explicitly what
`lazy` does impl
On Monday, 5 April 2021 at 05:22:22 UTC, frame wrote:
On Sunday, 4 April 2021 at 18:05:04 UTC, tsbockman wrote:
Thus, the solution is to use an explicit `delegate` instead of
`lazy`:
Yes, I forgot to mention that.
Could you please explain why you set 'scope' here? Isn't it
wanted to keep
On Tuesday, 6 April 2021 at 19:55:03 UTC, Alain De Vos wrote:
I have one very large text table I want to work with.
But I don't want to keep de table in memory, what do I use ?
Using an sql database is overkill in my setting.
There are 10 colums but millions of rows.
You might find memory mappe
On Wednesday, 9 June 2021 at 21:10:58 UTC, Marcone wrote:
std.file.append("file; \nApple");
std.file.append("file; \nBanana");
Result:
AppleBanana
Not all systems use the same char sequence for line breaks. In
particular, Microsoft Windows uses "\r\n".
You can use
[`std.ascii.newline`](ht
On Wednesday, 9 June 2021 at 19:13:10 UTC, JG wrote:
I found the following behaviour, as part of a more complicated
algorithm, unexpected. The program:
import std;
void main()
{
int n = 64;
writeln(123uL>>n);
}
produces:
123
I would expect 0.
What is the rati
(Responding out of order:)
On Friday, 2 July 2021 at 00:26:52 UTC, someone wrote:
But when you start attempting to declare @safe chunks of code
that actually DO things ... well, it seems end-of-the-story.
If you find yourself unable to get real work done in `@safe`
code, this is almost certai
On Saturday, 3 July 2021 at 16:06:33 UTC, Alexandru Ermicioi
wrote:
3. An edge case. Ex: You need to mutate some data and then
assume it is immutable in a constructor.
Can you give a valid example where that is necessary? The main
examples that I can think of either can be `@safe` with the rig
On Monday, 1 November 2021 at 21:32:21 UTC, Ali Çehreli wrote:
Joking aside, I liked the nested struct and its opAssign to
mimic internal `arr.length = 42` syntax. (I know it involves a
potentially expensive delegate but still...)
The nested struct is not needed. UFCS works for setters, too:
On Tuesday, 28 December 2021 at 07:54:56 UTC, frame wrote:
On Tuesday, 28 December 2021 at 06:38:03 UTC, Tejas wrote:
The workaround is okay, but I think we should file a bug
report for this.
This is very ~~stupid~~ undesirable behaviour
I agree. I'll just wait if somebody can explain why thi
Why does this code compile? Shouldn't the `isIntegral` import be
private to module `testB` unless I explicitly ask for it to be
public?
// testB.d
module testB;
import std.traits : isIntegral;
// testA.d
module testA;
void main(string[] args) {
import testB;
static assert(isIntegral!
On Sunday, 6 December 2015 at 11:10:44 UTC, Mike Parker wrote:
A very old bug.
https://issues.dlang.org/show_bug.cgi?id=314
Wow! 2006. Looks like it might get fixed soon, though:
https://github.com/D-Programming-Language/dmd/pull/3407
On Monday, 7 December 2015 at 22:38:03 UTC, Steven Schveighoffer
wrote:
It's an old bug, if it still exists. But in any case, the
description is terrible. A real bug report should be filed.
-Steve
Filed (https://issues.dlang.org/show_bug.cgi?id=15419) and fixed
(https://github.com/D-Programm
On Monday, 7 December 2015 at 20:56:24 UTC, John Carter wrote:
So whilst attempt to convert from a hex string (without the 0x)
to int I bumped into the @@@BUG@@@ the size of China
https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L2270
Is there a bugzilla issue number
Is there no way to do a simple binary search of a sorted array
using Phobos?
I found `SortedRange.contains`, but that just returns true/false.
I want the index of the element, or the element itself.
I also found `SortedRange.equalRange`, but that sounds like it
has an unreasonable amount of
On Tuesday, 15 December 2015 at 00:31:45 UTC, Jakob Ovrum wrote:
On Tuesday, 15 December 2015 at 00:22:37 UTC, tsbockman wrote:
I also found `SortedRange.equalRange`, but that sounds like it
has an unreasonable amount of (admittedly O(1)) overhead for
the (extremely common) case in which I am l
On Sunday, 27 December 2015 at 16:05:39 UTC, Gary Willoughby
wrote:
If I remove the post-increment of the y variable if works. Is
this an rvalue reference issue? Would you expect this to work?
This should work with *pre*-increment, but not post-increment.
Post-increment works like this:
int
Trying to compile this:
void main() @safe
{
import std.stdio;
stdout.flush();
}
Fails with this message:
Error: safe function 'main' cannot access __gshared data
'stdout'
Is this necessary? If so, what are the synchronization
requirements for access to `stdout`?
On Saturday, 2 January 2016 at 13:15:37 UTC, John Colvin wrote:
Casting away immutable can sometimes be necessary (e.g. when
talking to other languages), so I'm not sure it should be
disallowed, but it'd be great if it was somehow easier to catch
these bugs.
It should be disallowed in @safe c
On Saturday, 2 January 2016 at 16:48:41 UTC, Jack wrote:
So yeah I've been trying to experiment with the language when
I'm met with an Access Violation error.
So I've extracted a string from a file and used it as an index
for a dynamic array. Stripped code sample is :
///
On Saturday, 2 January 2016 at 16:48:41 UTC, Jack wrote:
[...]
Also, your sample reads from an external file, "read.txt". Either
give us the contents of that file, or change the sample so that
it is not required.
On Saturday, 2 January 2016 at 17:39:42 UTC, Jack wrote:
So I'll just send the whole file if you don't mind:
http://dpaste.com/11V5BYA (Line 174-183)
The contents of the .txt file is :
http://dpaste.com/3FVW5QR
I just checked it and it compiles but it does that strange
Access Violation error.
1 - 100 of 174 matches
Mail list logo