On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
The only safe values for a `bool` are 0 (false) and 1 (true).
AFAIK that was fixed and now full 8-bit range is safe.
On Tuesday, 4 June 2024 at 12:22:23 UTC, Eric P626 wrote:
I try to create a 2D array of fixed length and pass it in
parameter as a reference. Normally, in C, I would have used a
pointer as parameter, and pass the address of the array.
Not obvious what you're trying to do. How would you do it i
With accessor:
```
void main()
{
s_cell[] maze=make(5,5);
s_cell a=maze.get(1,2);
print_maze(maze);
}
void print_maze(s_cell[] maze)
{
}
s_cell[] make(int width, int height)
{
return new s_cell[width*height];
}
s_cell get(s_cell[] maze, int x, int y)
{
return maze[5*y+x]; //
1) arena allocator makes memory manageable with occasional cache
invalidation problem
2) no hashtable no problem
3) error handling depends on your code complexity, but even in
complex C# code I found exceptions as boolean: you either have an
exception or you don't
4) I occasionally use CTFE, w
It's a bug.
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 stac
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 ri
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 technical
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, str
Also what's the difference between null and empty phone number?
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 databas
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;
}
```
Bar.toString is typed `@system`.
Provide two functions and let the caller choose
```
void fun(ref Variant v) nothrow
{
}
void fun2(Variant v)
{
fun(v);
}
```
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.
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 decla
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) { sharedTable.remove(ke
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 unsharedTable.key
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, the
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 log
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` e
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:
https://learn.microsoft.com/en-us/dotnet/api/system.windows.fo
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 an
My point is you know you're just picky.
https://github.com/dominikh/go-tools/issues/917
How go programmers cope with this feature?
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
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);
```
I suppose you write a custom logger for that or take an already
written one from code.dlang.org
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
Probably bug in druntime, v-functions shouldn't have
`pragma(printf)`, because they don't have arguments to check.
Maybe the problem is with va_list, try to compile with
-mtriple=riscv64-unknown-linux -mcpu=generic-rv64
Naming is hard.
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 purel
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 wa
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.
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 = 0
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.
You can declare them
```
extern(C) void _InterlockedExchangeAdd(){ assert(false); }
```
Is GENERIC_WRITE awailable?
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");
}
writeln(result
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 fa
Maybe you're not supposed to print text while reading?
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.
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 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 < s
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} o
Docs say SSL_get0_peer_certificate was added in openssl 3.
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`.
TBH modern computers are obscenely powerful, I just spent weeks
on celeron 1.8GHz 2mb L2 cache 2gb ram computer and didn't see
any slowness on it despite some bloated software in python and a
strange text editor pluma that ate 150mb ram just editing a plain
text file, I swear it's not based on
On Tuesday, 16 July 2019 at 01:38:49 UTC, evilrat wrote:
Also from what I see MS done this intentionally, means they
either no longer loves COM or there was some other good reason.
Primary consumer of COM interfaces is Visual Basic. It was really
only Bill Gates who loved Basic, he wrote a Bas
On Sunday, 21 July 2019 at 07:04:00 UTC, rikki cattermole wrote:
COM is used heavily in WinAPI since about Vista. Pretty much
all new functionality has been exposed by it and NOT
extern(Windows) functions which was the standard during up to
about XP (for example notification icons would today b
On Thursday, 25 July 2019 at 12:46:48 UTC, Oleg B wrote:
What reason for such restrictions? It's fundamental idea or
temporary implementation?
I think it's a dmd limitation. Currently it has a bug that it can
still generate code for ctfe templated functions, and they will
fail to link if they
On Sunday, 28 July 2019 at 12:56:12 UTC, BoQsc wrote:
Right now, I'm thinking what is correct way to run another .d
script from a .d script. Do you have any suggestions?
You mean something like execute(["rdmd", "another.d"]); ?
On Wednesday, 31 July 2019 at 22:30:52 UTC, Alexandre wrote:
1) Improve as a programmer
2) Have fun doing programs
Thats it basically. I am planning to study all "free" time I
have. I am doing basically this since last year.
Try Basic. It has builtin graphics, seeing you program draw is
quit
You're probably interested in readiness, not possibility?
On Monday, 26 August 2019 at 12:02:12 UTC, GreatSam4sure wrote:
I want customizable GUI toolkit like JavaFX and adobe spark
framework in D.
DWT was translated from java SWT, you can do the same for JavaFX,
D is heavily based on java and there's an automatic translation
tool from java to D.
Maybe something like this
https://forum.dlang.org/post/hloitwqnisvtgfoug...@forum.dlang.org
On Thursday, 5 September 2019 at 12:46:06 UTC, berni wrote:
OK. This are two solutions and although I'll probably not going
to use any of those (due to other reasons), I still don't
understand, why the original approach does not work. If I've
got a book an put it in a box and later I'll get it
Maybe you upgraded SFML and now binding doesn't match?
https://ddbus.dpldocs.info/ddbus.bus.requestName.html
On Sunday, 29 September 2019 at 02:09:56 UTC, Hossain Adnan wrote:
On Saturday, 28 September 2019 at 13:37:12 UTC, Kagamin wrote:
https://ddbus.dpldocs.info/ddbus.bus.requestName.html
It requires a Connection type which I cannot find in the API.
It's in ddbus.thin, missing documentation comm
On Sunday, 29 September 2019 at 02:09:56 UTC, Hossain Adnan wrote:
On Saturday, 28 September 2019 at 13:37:12 UTC, Kagamin wrote:
https://ddbus.dpldocs.info/ddbus.bus.requestName.html
It requires a Connection type which I cannot find in the API.
It's in ddbus.thin, missing documentation comm
On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote:
Does DMD/LDC avoid range-checking in slice-expressions such as
the one in my array-overload of `startsWith` defined as
bool startsWith(T)(scope const(T)[] haystack,
scope const(T)[] needle)
{
if (haystack.l
On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote:
Does DMD/LDC avoid range-checking in slice-expressions such as
the one in my array-overload of `startsWith` defined as
bool startsWith(T)(scope const(T)[] haystack,
scope const(T)[] needle)
{
if (haystack.l
On Wednesday, 13 November 2019 at 16:43:27 UTC, IGotD- wrote:
On Wednesday, 13 November 2019 at 15:30:33 UTC, Dukc wrote:
I'm not 100% sure what managed pointers mean -Are they so that
you can't pass them to unregistered memory? A library solution
would likely do -wrap the pointer in a struct
On Monday, 18 November 2019 at 06:44:43 UTC, Joel wrote:
```
http://www.w3.org/2001/XMLSchema-instance";>
```
You're missing a closing tag.
https://issues.dlang.org/show_bug.cgi?id=19495#c1
On Thursday, 19 March 2020 at 13:10:29 UTC, Steven Schveighoffer
wrote:
Similar for me but not GameMaker but RPG Maker.
I've seen all your work on the language, and this is a pretty
good endorsement.
Not sure if I'm ready to pay for it though, I want to make sure
his motivation/drive is not
Maybe if you teach dparse to do this check.
On Monday, 27 April 2020 at 10:28:04 UTC, mark wrote:
I renamed the class shown in my previous post from View to
InnerView, then created a new View class:
class View : ScrolledWindow {
import qtrac.debfind.modelutil: NameAndDescription;
InnerView innerView;
this() {
super(
On Monday, 18 May 2020 at 17:02:02 UTC, BoQsc wrote:
The important question is: how can we change the name/title of
this Command Line application.
As the simplest solution, you can set the window title in
shortcut properties.
On Monday, 18 May 2020 at 17:20:17 UTC, BoQsc wrote:
It would be great if we could change/customise the icon of the
Command line application that run the HelloWorld application.
But I have a bad feeling that it is probably not possible
without a GUI library.
I think the window icon is just th
On Thursday, 21 May 2020 at 17:19:10 UTC, Konstantin wrote:
Hi all! I will try to ask again(previous two posts still have
no answers) : are there any site/page/docs somewhere to track
actual info about @nogc support in language itself and in
phobos library? Or, at least plans to extend such sup
Logic is apparently still in flux, too early to document.
that's
int id=parameters[param].id;
string param="aa";
parameters[param]=Parameter();
in id=parameters[param].id;
Not sure how much synchronization do you want to do.
import gio.Application : GioApplication = Application;
import gtk.Application : Application;
import gtk.ApplicationWindow : ApplicationWindow;
import gtk.ProgressBar : ProgressBar;
import glib.Timeout : Timeout;
import gtkc.gtktypes : GApplicat
If you want to use them from D, you need those classes and
methods declared in the D language, in text.
On Friday, 26 June 2020 at 10:12:09 UTC, Jacob Carlborg wrote:
Downloading files over TLS. This seems that it's something that
should be quite simple to do. My high level goals are
cross-platform and easy distribution. I don't need anything
fancy just a simple API like this:
download("https:/
std.concurrency is for noninteractive appications, the approach
with gui timer was the correct one.
On Saturday, 27 June 2020 at 07:51:21 UTC, adnan338 wrote:
On Saturday, 27 June 2020 at 07:31:56 UTC, Kagamin wrote:
std.concurrency is for noninteractive appications, the
approach with gui timer was the correct one.
Thank you. That works but my progress bar is sometimes getting
stuck because
On Sunday, 28 June 2020 at 07:09:53 UTC, Виталий Фадеев wrote:
I want light-weight runtime !
How to ?
Runtime provides language features that rely on extra code.
Removing that code from runtime means to give up on corresponding
language features. This way you can implement only features you
On Saturday, 27 June 2020 at 14:49:34 UTC, James Gray wrote:
I have produced something which essentially reproduces my
problem.
What is the problem? Do you have a leak or you want to know how
GC works?
On Monday, 29 June 2020 at 19:55:59 UTC, Steven Schveighoffer
wrote:
Yep, for sure. I'll file an issue. Anyone know why the calling
convention would differ?
It's easier to enforce left to right evaluation order this way:
arguments are pushed to stack as they are evaluated, which is
pascal cal
bson_t* bson_new_from_json(in char* data, long len, bson_error_t*
error);
string str_utf8 = "{\"a\":1}";
bson_error_t error;
auto bson = bson_new_from_json(str_utf8.ptr, str_utf8.length,
&error);
You have a wrong declaration for bson_error_t too.
1 - 100 of 926 matches
Mail list logo