WebFreak said you can just use trace(), info() etc. inside
threads. It is thread-safe by default.
```d
module app;
import std.stdio;
import std.logger;
void main() {
//auto file = File("logFile.log", "w");
auto file = stderr; // stdout
sharedLog = cast(shared)new
Forgot the following flags:
`-L=-merge_zero_fill_sections -L=-no_exported_symbols
-L=-no_eh_labels -L=-dead_strip_dylibs`
So the full command is:
```
ldc2 --release --O3 --flto=full -fvisibility=hidden
-defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L=-dead_strip -L=-x
-L=-S -L=-lz
On Wednesday, 12 July 2023 at 01:55:00 UTC, mw wrote:
```
import std.experimental.logger;
void main() {
std.experimental.logger.sharedLog.trace("msg");
}
```
See examples at https://dlang.org/phobos/std_logger.html
and https://dlang.org/phobos/std_logger_filelogger.html
```d
import
But is there really no other way to immediately point a static
array to a variable?
Looks like this is not implemented yet:
- https://dlang.org/spec/hash-map.html#static_initialization
Would a static constructor be okay? This way the static data
is not initialized at every `new` and object
Works fine, if you add a semicolon at the end.
```d
import std.stdio;
void main() {
string[][string] arr = [
"one": ["abc", "def"],
"two": ["ghi", "jkl"],
"three": ["mno", "pqr"]
];
writeln(arr);
writeln(arr["two"]);
writeln(arr["two"][0]);
}
```
On Saturday, 15 July 2023 at 23:24:27 UTC, Alexander Zhirov wrote:
There are the same number of elements everywhere (in the
internal array).
Sorry, forgot that part.
Just add the size of the internal array (2 in this case):
```d
string[2][string] arr = [
"one": ["abc", "def"],
On Wednesday, 12 July 2023 at 05:27:27 UTC, mw wrote:
But what's wrong with my code? the strange compiler error?
Might be a bug/issue in the logger module.
`sharedLog` uses the `shared` attribute,
but the base class for everything ("abstract class Logger")
does not use the `shared` attribute
On Tuesday, 23 January 2024 at 17:54:25 UTC, bachmeier wrote:
Here's a reduced version of one of the most bizarre bugs I've
dealt with in any language. The only reason I didn't move on to
another language was because I was too busy at the time.
The code allows for initial values if the index
On Tuesday, 23 January 2024 at 18:15:29 UTC, Stephen Tashiro
wrote:
If the constructor of a class needs to create an array of
structs whose dimensions are inputs, what's the syntax for
doing this?
For a non-example, the following program errors in main()
because in t.array[][] "index [0] is
On Monday, 22 January 2024 at 17:15:55 UTC, bachmeier wrote:
I get incorrect results, and when I'm lucky, my program
segfaults because I accessed something I shouldn't. When I'm
not, it silently and happily gives me the wrong answer.
Maybe a compiler warning (not error) would help with
On Thursday, 8 February 2024 at 18:43:09 UTC, H. S. Teoh wrote:
11 years and we still haven't fixed all the problems?! That's
... wow.
Incredible! Seems like D is experiencing featuritis.
Priorities may be wrong.
Instead of bug fixing and stabilization, people concentrate on
getting new
On Friday, 9 February 2024 at 12:15:29 UTC, Sergey wrote:
Rust, Nim, Zig, Odin…?
Here is the Forum for D(lang). ;)
But it is fine to see what others have..
Teach on their experience is useful
This is how research is going
Sorry, I probably got confused by the use of different languages
in
On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote:
It seems I cannot pass e.g. an int argument to a Variant
function parameter. What's the simplest way to work around this
restriction?
Just tell the compiler clearly what you want.
```d
import std;
void f(Variant x) {
On Monday, 22 January 2024 at 08:35:01 UTC, Joel wrote:
I've lost interest in the video, looks like horrible syntax
(F#).
Nonetheless, this usually used with Objects (new class/struct
instances), like so:
```d
import std;
struct Person {
string name, email;
ulong age;
auto
On Monday, 22 January 2024 at 08:54:21 UTC, Danilo wrote:
It's common OOP style in some frameworks.
With latest D you can also just use named parameters:
```d
import std;
struct Person {
/*private*/ string name, email;
/*private*/ ulong age;
}
void main() {
auto p = Person(
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote:
VS:`C++`
```d
struct Person {
string name, email;
ulong age;
}
Person a{"n","email",33};
```
It's not much different in D. ;)
```d
import std;
struct Person {
string name, email;
ulong age;
}
void main() {
auto p =
On Sunday, 21 January 2024 at 16:05:40 UTC, Gavin Gray wrote:
The following code:
ulong charlie = 11;
long johnstone = std.algorithm.comparison.max(0, -charlie);
writeln(format!"johnstone %s"(johnstone));
Results in (without any warning(s)):
johnstone -11
However you choose to look at
On Friday, 2 February 2024 at 11:31:09 UTC, Anonymouse wrote:
On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant
wrote:
It seems I cannot pass e.g. an int argument to a Variant
function parameter. What's the simplest way to work around
this restriction?
The easiest thing would be to
On Tuesday, 27 February 2024 at 22:05:48 UTC, Liam McGillivray
wrote:
Looking at the code examples on the Raylib and SFML website,
they look similar in complexity of getting started, but I like
it that the Raylib website has lots of simple demonstration
programs on the website with the code
On Wednesday, 28 February 2024 at 07:56:16 UTC, Liam McGillivray
wrote:
```
DrawText("Open Emblem", 180, 300, 64, Colors.RAYWHITE);
```
So why is it that one of these functions, but not the other is
allowing D strings in place of C-style strings?
C is expecting null-terminated chars. D
Examples were moved, so it‘s in the same place now:
- https://github.com/schveiguy/raylib-d
- https://github.com/schveiguy/raylib-d_examples
21 matches
Mail list logo