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
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 =
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 = {
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
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 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 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?
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
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
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`
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
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
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 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
(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
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
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
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
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 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
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
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
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`
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
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
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.
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 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,
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)
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
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,
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 ==
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
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
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)
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
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
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
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 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
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
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
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
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,
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 :
https://dlang.org/spec/struct.html#struct-copy-constructor
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 =
}
private void impl();
}
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
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 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
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
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
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]
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:
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:
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.
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
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
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
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
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
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 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 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.
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
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
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 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 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
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
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 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
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
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 =
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:
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) {
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 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
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.)
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
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
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;
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 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
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
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
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
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
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
On Tuesday, 26 July 2016 at 15:11:00 UTC, llaine wrote:
I'm using D since a few month now and I was wondering why
people don't jump onto it that much and why it isn't the "big
thing" already.
D2 is under active development. Bugs get fixed, bottlenecks get
optimized, and features get added or
On Wednesday, 1 June 2016 at 19:59:51 UTC, Mark Isaacson wrote:
I'm trying to create a type that for all intents and purposes
behaves exactly like an int except that it limits its values to
be within a certain range [a,b]. Theoretically, I would think
this looks something like:
...
It looks
On Wednesday, 18 May 2016 at 01:46:37 UTC, tsbockman wrote:
Shouldn't a union type always have an `alignof` at least as
great as the `alignof` for its largest member?
Apparently not; it's actually DMD and LDC that are wrong here:
http://bugzilla.gdcproject.org/show_bug.cgi?id=226
On Saturday, 21 May 2016 at 01:09:42 UTC, Alex Parrill wrote:
On Friday, 20 May 2016 at 22:10:51 UTC, tsbockman wrote:
If that's not a satisfactory answer, please show some specific
examples of code that you don't know how to make work without
VK_NULL_HANDLE so that I can propose a workaround.
On Saturday, 21 May 2016 at 01:53:21 UTC, Mike Parker wrote:
When binding to a C library, it's desirable to have as close to
the original C API as possible so that you *can* drop C
snippets and examples into D code and have them just work.
Obviously, 100% compatibility is not possible, but it
On Friday, 20 May 2016 at 13:39:50 UTC, Alex Parrill wrote:
(How) can I make a constant that is either zero or null
depending on how it is used?
In the general case, I don't think this is possible in D
currently. (It will become possible if the proposed "multiple
alias this" ever gets
On Thursday, 19 May 2016 at 20:14:48 UTC, vit wrote:
Is this a bug?
Yes. I've filed a report:
https://issues.dlang.org/show_bug.cgi?id=16050
Is this a bug?
---
module app;
union Foo(A, B) {
A a;
B b;
}
void main() {
alias F = Foo!(double, ulong);
import std.stdio, std.algorithm;
writefln("sizeof: (%s >= %s) == %s",
F.sizeof, max(double.sizeof, ulong.sizeof),
F.sizeof >= max(double.sizeof,
On Friday, 13 May 2016 at 06:05:14 UTC, Andrew Edwards wrote:
Additionally, what's the best way to handle nested #ifdef's?
Those that appear inside structs, functions and the like... I
know that global #ifdef's are turned to version blocks but
versions blocks cannot be used inside classes,
On Friday, 13 May 2016 at 01:16:36 UTC, Andrew Edwards wrote:
command: dmd -run mod inc
output:
Undefined symbols for architecture x86_64:
"_D3inc5printFZv", referenced from:
__Dmain in mod.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit
On Friday, 13 May 2016 at 04:59:23 UTC, Andrew Edwards wrote:
Is there a way to reproduce the same behavior? Are there
reason's for not allowing this functionality or am I just
misunderstanding and going about things the wrong way?
[1] same result whether placed before or after the
On Friday, 6 May 2016 at 02:57:59 UTC, Jeremy DeHaan wrote:
In core.exception, we have a lovely function called
onInvalidMemoryOperationError(). This function is marked as
nothrow (plus other annotations). This function literally does
nothing except throwing an error. How can it be marked as
1 - 100 of 172 matches
Mail list logo