Try to compile in debug mode, maybe you breach some contract.
Maybe Ada.
On Sunday, 29 November 2020 at 19:09:07 UTC, Mark wrote:
Looking at Ada now.
I found: Ada is not good for me. It has no augmented
assignment. It's just that I want DRY because I use very
verbose variable names
Using a reasonable naming convention should be much easier than
looking for a
On Thursday, 10 December 2020 at 21:01:30 UTC, Marcone wrote:
In this very generic example && not work to finalize the
instruct and start a new instruct. Yes, I know dmd can build
and run without it, but this is only a example.
execute(["cmd", "/c", "dmd test.d", "&&", "start test.exe"]);
On Sunday, 8 November 2020 at 10:47:34 UTC, Per Nordlöw wrote:
dchar
Surrogate pairs are used in rules because java strings are utf-16
encoded, it doesn't make much sense for other encodings.
The delegate is stored on the stack of the calling thread, the
created thread loads it from there, but the calling thread
doesn't wait for that and clobbers the stack right away. If you
were lucky your code would crash.
On Saturday, 14 November 2020 at 23:30:58 UTC, Adam D. Ruppe
wrote:
On Saturday, 14 November 2020 at 23:20:55 UTC, Martin wrote:
Is this intentional?
In the current language design, yes.
It's a bug, it breaks data sharing guarantees.
You can compare like time1 > time2 + 100.msec, though posix
specifies only second precision.
You can make it opt in, it's insurance.
You can define a symbol that will conflict with GC and prevent
linking with it.
On Wednesday, 9 June 2021 at 19:13:10 UTC, JG wrote:
produces:
123
I would expect 0.
What is the rationale for this behaviour or is it a bug?
Processor just takes lower 6 bits for the shift amount and those
hold zero in your case, shifting by 65 will shift by 1.
https://forum.dlang.org/post/koxqrqqzadfefbgkd...@forum.dlang.org
Add libraries that provide missing symbols.
On Thursday, 18 March 2021 at 17:57:30 UTC, Patrick Schluter
wrote:
It's important to understand that [] is just a practical syntax
for a fat pointer.
Thinking of [] just as a fancy pointer helps imho to clarify
that the pointed to memory nature is independant of the pointer
itself.
I
struct S
{
this(string s)
{
type = Type.type1;
}
this(int n)
{
type = Type.type2;
}
Type type;
int n;
}
int value(S s)()
{
static if(s.type == Type.type2) {
// do something
mangleof should give _D4file6addOneFiZi, not _D6patron6addOneFiZi
I suppose commercial vendors aren't interested in suckless
paradigm, so this library is for people and only for people.
On Wednesday, 3 March 2021 at 20:54:43 UTC, Anthony Quizon wrote:
I'm having some success pulling out small bits of code from
other libraries and keeping things minimal and c-style-ish.
If you're really ok with minimalism, I'm writing such a library
https://filebin.net/7gtyh5j01gk1ofly
I
struct A
{
private int[] a;
this(int[] b){a=b;}
int[] c(){ return a; }
@disable void opAssign();
}
struct B
{
A a;
this(int){ a=new int[5]; }
int[] b(){ return a.c; }
void f(){ a=new int[5]; }
}
On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote:
Why can't I just use: import vibe.vibe; for import packages
like Nim or Python? Why I still use DUB?
Theoretically an rdmd-like tool can automatically infer
dependencies from imports (autodub?). But it can also easily
expose you to a
On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote:
Maybe I am just too short in D, but I wanted to find out if it
is possible to create classes dynamically. My problem is, I
just don't know where to start reading. Maybe at mixin
templates?
CreateClassWithName!("MyDynamicClassName");
class foo {
this ( foo p /* , other params */ ) {
parent = p;
}
foo create() {
return new foo(this);
}
void use() {
foo f = create();
}
foo parent;
}
On Friday, 16 April 2021 at 08:31:27 UTC, Imperatorn wrote:
One example would be a repl
That has little to do with what OP meant.
On Wednesday, 18 August 2021 at 17:56:53 UTC, Ruby The Roobster
wrote:
When I removed those two lines of code, the program ran
perfectly without displaying any error or throwing any
exception...
The errors aren't always nicely located and can be elsewhere. Try
to write a minimal runnable
Maybe you're trying to load a 32-bit library into a 64-bit
process.
If you want only address, you can keep it as size_t:
ubyte[10] Arr;
immutable size_t Address;
static this() {
Address = cast(size_t)([0]);
}
Yes, the `return` attribute is what should do it. You also need
to compile the code with -dip1000 option.
On Tuesday, 12 October 2021 at 08:19:01 UTC, jfondren wrote:
and string literals weren't reliably in read-only memory as
recently as early 2017:
https://github.com/dlang/dmd/pull/6546#issuecomment-280612721
Sometimes sections have defined symbols for start and end, you
can check if the
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote:
Hi there,
I'm new in dlang I specially like betterC. I was hoping that d
fibers would be implemented in without using classes, but there
are not.
On windows you can use the fiber api
On Sunday, 3 October 2021 at 22:22:48 UTC, rjkilpatrick wrote:
```d
import std.stdio : writeln;
import std.variant;
import std.conv;
// Arbitrary super class
class SuperClass {
this() {
}
}
// Derived class with members
class DerivedClass : SuperClass {
public:
this(float a) {
Actually C runtime is many megabytes in size.
On Monday, 27 December 2021 at 11:21:54 UTC, rempas wrote:
So should I just use UTF-8 only for Linux? What about other
operating systems? I suppose Unix-based OSs (maybe MacOS as
well if I'm lucky) work the same as well. But what about
Windows? Unfortunately I have to support this OS too with
D strings are plain arrays without any text-specific logic, the
element is called code unit, which has a fixed size, and the
array length specifies how many elements are in the array. This
model is most adequate for memory correctness, i.e. it shows what
takes how much memory and where it will
On Monday, 27 December 2021 at 07:29:05 UTC, rempas wrote:
How can you do that? I'm trying to print the codes for them but
it doesn't work. Or you cannot choose to have this behavior and
there are only some terminals that support this?
Try it on https://en.wikipedia.org/wiki/Teletype_Model_33
You can use the string type to hold non-ascii characters. Just a
substring of another string.
Unsigned integers aren't numbers.
assert(-abs(1)<0);
`debug(func1)writefln(...)`
But specify a global debug version for the compiler:
`dmd -debug=func1 app.d`
You can do something like
```d
enum LogSettings
{
func1,func2,func3
}
alias logger!LogSettings logf;
void func1()
{
logf(...);
}
```
Then the logger can inspect symbols in the template argument and
compare their names to the function name.
On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote:
Why are we even escaping them by default, it should be the
other way around, that slashes are only escaped if you ask for
it; that's how it literally is in almost every JSON library.
Really? I always see escaped slashes in JSON, e.g.
Isn't cross-linker enough? My regular mingw build of ld says it
supports elf64-x86-64 traget, so I assume something like this
should be enough:
ld -b elf64-x86-64 -L lib --dynamic-linker
/lib64/ld-linux-x86-64.so.2 --as-needed --gc-sections -s
lib/crt1.o lib/crti.o my.o -lc lib/crtn.o
3AAF1A18E61F6FAA3B7193E4DB8C5218B9329CF8 is 0xDB8C5218B9329CF8
This shortening was supposed to improve user experience.
On Friday, 8 September 2023 at 13:32:00 UTC, rempas wrote:
On Friday, 8 September 2023 at 13:05:47 UTC, evilrat wrote:
```d
import core.stdc.stdlib;
import core.stdc.stdio;
alias u64 = ulong;
alias i64 = long;
struct Vec(T) {
private:
T* _ptr = null; // The pointer to the data
u64 _cap =
The .exe is produced by the linker, which works with files: it
takes one or more .obj files with program code and links them
into and .exe file. I heard ldc has builtin linker or something
like that, so hypothetically might be able to link on the fly.
Try to run clang with -v option and compare with gcc.
On Sunday, 10 July 2022 at 21:27:08 UTC, Hipreme wrote:
"Your app has entered a break state, but there is no code to
show because all threads were executing external code
(typically system or framework code)."
Open the threads window and click on threads there, their stack
will be in the
On Tuesday, 19 July 2022 at 18:05:34 UTC, Antonio wrote:
In a relational database, `NULL` is not the same that `""`...
and `NULL` is not the same that `0`. Are semantically
different and there are database invariants (like foreign keys)
based on it. Trying to "mix" this concepts in a
On Tuesday, 12 July 2022 at 20:36:03 UTC, Antonio wrote:
Honestly, it is difficult to understand for newcomers... there
is a reason, but there is a reason in javascript for `0 == ''`
too
People would have different preferences there. Difference between
null and empty is useless. D does the
On Monday, 18 July 2022 at 21:23:32 UTC, Antonio wrote:
I will study it in detail and report (if required). May be, I
will write the DTO problem with D article if I find time in
august.
In my experience null and empty in DTOs usually play the same
logical role. It's a very contrived
This is how to do it the D way:
```
int main(string[] args)
{
string ch1 = "Hello World!";
char[] ch2="Hello World!".dup;
string s1=ch1[1..$];
char[] s2=ch2[1..$];
writeln(s1);
writeln(s2);
return 0;
}
```
On Tuesday, 19 July 2022 at 10:29:40 UTC, Antonio wrote:
The summary is that a DTO that works like a Map needs to
represent the absent key ant this is not the same that the Null
value
Example:
```d
struct Null { /*...*/ }
struct Undefined { /*...*/ }
struct ContactDto {
DtoVal!(Undefined,
Also what's the difference between null and empty phone number?
ldc2 -link-defaultlib-shared=false or something like that
Looks like explicitly initialized variable in this case allocates
array literal. Uninitialized variable is initialized with init
pattern. This may be correct as uninitialized variable isn't
guaranteed to hold a value most useful for you, it's only
guaranteed to hold a defined value.
On Friday, 28 October 2022 at 02:46:42 UTC, ryuukk_ wrote:
I'm just right now having an issue with glibc version mismatch
for my server
Just compile with an old enough glibc, 2.14 works for me.
Provide two functions and let the caller choose
```
void fun(ref Variant v) nothrow
{
}
void fun2(Variant v)
{
fun(v);
}
```
Bar.toString is typed `@system`.
On Friday, 18 November 2022 at 17:57:25 UTC, H. S. Teoh wrote:
You're looking at it the wrong way. The kind of issues having
const
would solve is like when your function takes parameters x, y,
z, and
somewhere deep in the function you see the expression `x +
y*z`. If x,
y, and z are const,
On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin
wrote:
I am still trying to find answers to the following questions:
1. Is it somehow possible to get rid of the dub single file
scheme, and
e.g. interpret a full dlang script at runtime?
If there was an interpreter like
```
But embedded sdl is likely to be dwarfed by the actual code
anyway.
Another idea is to separate the script and interpreter then
compile them together.
```
--- interp.d ---
import script;
import ...more stuff
...boilerplate code
int main()
{
interpret(script.All);
return 0;
}
--- script.d ---
#! ?
module script;
import mind;
auto All=Task(...);
...more
This works for me:
```
synchronized final class SyncAA(K, V)
{
this(K key, V val) { sharedTable[key]=val; }
V opIndex(K key) { return sharedTable[key]; }
V opIndexAssign(V value, K key) { return sharedTable[key]=value;
}
const(K[]) keys() const { return
Try this:
```
synchronized final class SyncAA(K, V)
{
V opIndex(K key) { return sharedTable[key]; }
V opIndexAssign(V value, K key) { return sharedTable[key]=value;
}
const(K[]) keys() const { return unsharedTable.keys; }
void remove(K key) { sharedTable.remove(key); }
With allocation:
```
synchronized final class SyncAA(K, V)
{
V opIndex(K key) { return sharedTable[key]; }
V opIndexAssign(V value, K key) { return sharedTable[key]=value;
}
const(K[]) keys() const { return unsharedTable.keys; }
void remove(K key) {
On Monday, 13 March 2023 at 00:32:07 UTC, zjh wrote:
Thank you for your reply, but is there any way to output `gbk`
code to the console?
I guess if your console is in gbk encoding, you can just write
bytes with stdout.write.
static is thread local by default.
```
module main;
import app;
import core.thread;
int main(string[] args)
{
static shared int result;
static shared string[] args_copy;
static void app_thread()
{
App app = new App();
result = app.run(args_copy);
}
https://dlang.org/phobos/std_stdio.html#rawWrite
https://github.com/dominikh/go-tools/issues/917
How go programmers cope with this feature?
This guid is (int,short,short,byte[8]) in little endian byte
order. So if you want to convert it to big endian, you'll need to
swap bytes in those int and two shorts.
```
ubyte[] guid=...
int* g1=cast(int*)guid.ptr;
*g1=bswap(*g1);
```
This guid is (int,short,short,byte[8]) in little endian byte
order. So if you want to convert it to big endian, you'll need to
swap bytes in those int and two shorts.
```
ubyte[] guid=...
int* g1=cast(int*)guid.ptr;
*g1=bswap(*g1);
```
On Friday, 10 February 2023 at 21:52:02 UTC, ProtectAndHide wrote:
Well in Swift, there is no problem .. at all.
Why is it a problem in D then? (and I mean technically).
What about the increment operator `++` ?
On Monday, 13 February 2023 at 08:22:06 UTC, ProtectAndHide wrote:
Chris Lattner outlines the reasons for removing it in Swift 3.0
here:
https://github.com/apple/swift-evolution/blob/main/proposals/0004-remove-pre-post-inc-decrement.md
So your complaint is that you agree with Chris Lattner
My point is you know you're just picky.
On Saturday, 4 February 2023 at 13:31:41 UTC, Alexander Zhirov
wrote:
I understand that programming under Windows is a shame for a
programmer, but is there really no ready-made solution for
using the system log in Windows?
It would be a logging library like log4j that would have
different
On Monday, 23 January 2023 at 00:36:36 UTC, thebluepandabear
wrote:
It's not a freedom issue, it's a library-design issue. Some
libraries want to incorporate a namespace-like design to force
the user to be more 'explicit' with what they want.
SFML has a `Keyboard` namespace which has a `Key`
On Friday, 10 February 2023 at 14:17:25 UTC, Kagamin wrote:
Pretty sure you can strip namespaces in any language that has
namespaces, C# routinely does it and refers to all types with
their nonqualified names. It even has Keys enum:
Maybe the problem is with va_list, try to compile with
-mtriple=riscv64-unknown-linux -mcpu=generic-rv64
Naming is hard.
Probably bug in druntime, v-functions shouldn't have
`pragma(printf)`, because they don't have arguments to check.
You try to use C declarations, but they are specific to each C
library, and different C libraries have different declarations,
so headers can't decide which C library declarations to use. Try
-mtriple=riscv32-unknown-linux
Worked for me on ldc 1.20
https://forum.dlang.org/post/vuxuftogvszztdrrt...@forum.dlang.org
I suppose you write a custom logger for that or take an already
written one from code.dlang.org
On Friday, 21 July 2023 at 23:40:44 UTC, mw wrote:
Is there a way to let it report on the spot when it happens?
On linux if you catch an exception and call abort, the debugger
will show you where abort was called, on windows you can call
DebugBreak function, the debugger will show where it
On Friday, 28 July 2023 at 03:54:53 UTC, IchorDev wrote:
I was told that using `__gshared` is quite a bit faster at
runtime than using `shared`, but I also don't really know
anything concrete about `shared` because the spec is so
incredibly vague about it.
The difference between them is
You will also need crt1.o, crti.o, crtn.o and libc.a
Your error is using allocating the object with malloc. Since gc
doesn't see your AA, the AA is freed and you get UAF.
You can just post with a new title.
It was mostly fine, such types are not supposed to be immutable,
but recently came an idea of reference counted strings, which
need to be immutable for being strings.
On Tuesday, 13 February 2024 at 23:57:12 UTC, Ivan Kazmenko wrote:
I do use lengths in arithmetic sometimes, and that leads to
silent bugs currently. On the other hand, since going from 16
bits to 32 and then 64, in my user-side programs, I had a flat
zero bugs because some length was 2^{31}
On Thursday, 8 February 2024 at 05:56:57 UTC, Kevin Bailey wrote:
How many times does the following loop print? I ran into this
twice doing the AoC exercises. It would be nice if it Just
Worked.
```
import std.stdio;
int main()
{
char[] something = ['a', 'b', 'c'];
for (auto i = -1; i <
Docs say SSL_get0_peer_certificate was added in openssl 3.
Add more debugging?
```
bool done = false;
while (!done) {
writeln(1);
auto result = ["echo", "Hello World"].execute;
if (result.status != 0)
{
writeln(2);
throw new Exception("echo failed");
}
Maybe you're not supposed to print text while reading?
Maybe write and read lock each other, try to use puts:
```
bool done = false;
while (!done) {
puts("1");
auto result = ["echo", "Hello World"].execute;
if (result.status != 0)
{
writeln(2);
throw new Exception("echo
Is GENERIC_WRITE awailable?
You can declare them
```
extern(C) void _InterlockedExchangeAdd(){ assert(false); }
```
Looks like the context is currently passed for nested functions,
not for nested classes.
On Thursday, 25 January 2024 at 20:11:05 UTC, Stephen Tashiro
wrote:
void main()
{
ulong [3][2] static_array = [ [0,1,2],[3,4,5] ];
static_array[2][1] = 6;
}
The static array has length 2, so index 2 is out of bounds, must
be 0 or 1.
I have an idea to estimate how long strlen takes on an exabyte
string.
On Sunday, 7 April 2024 at 06:46:39 UTC, Liam McGillivray wrote:
instantiated from here: `front!char`
Looks like autodecoding, try to comment `canFind`.
801 - 899 of 899 matches
Mail list logo