Re: Why is this not allowed?

2024-10-05 Thread Sergey via Digitalmars-d-learn
On Saturday, 5 October 2024 at 10:35:30 UTC, ryuukk_ wrote: On Saturday, 5 October 2024 at 06:43:00 UTC, Richard (Rikki) Andrew Cattermole wrote: I don't know why it isn't supported. Its very useful with bindings to C. The parser should be able to swap it to a named instance with a generated

Re: Why is this not allowed?

2024-10-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 5 October 2024 at 06:35:57 UTC, ryuukk_ wrote: Why is this allowed ```D struct EntityDef { struct { int hp; } } ``` But not this fucking thing? ```D struct EntityDef { struct { int hp; } stats; } ``` Let me name my shit No, i don't wan

Re: Why is this not allowed?

2024-10-05 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 5 October 2024 at 16:40:46 UTC, Salih Dincer wrote: On Saturday, 5 October 2024 at 06:35:57 UTC, ryuukk_ wrote: No, i don't want to do: ```C struct EntityDef { struct Stats { int hp; } stats; } ``` Repeating the same name 3 times, i should go back to the ston

Re: Why is this not allowed?

2024-10-05 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 5 October 2024 at 06:35:57 UTC, ryuukk_ wrote: No, i don't want to do: ```C struct EntityDef { struct Stats { int hp; } stats; } ``` Repeating the same name 3 times, i should go back to the stone age too no? C and all other C like languages allow me to be c

Re: Why is this not allowed?

2024-10-05 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 5 October 2024 at 06:43:00 UTC, Richard (Rikki) Andrew Cattermole wrote: I don't know why it isn't supported. Its very useful with bindings to C. The parser should be able to swap it to a named instance with a generated name. Let's PR and let's merge

Re: Why is this not allowed?

2024-10-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I don't know why it isn't supported. Its very useful with bindings to C. The parser should be able to swap it to a named instance with a generated name.

Interfacing with Rust

2024-10-04 Thread Matheus Catarino via Digitalmars-d-learn
https://forum.dlang.org/post/dudpbkerfrdlnggiz...@forum.dlang.org On Saturday, 1 October 2022 at 03:14:44 UTC, mw wrote: extern(C++)? Why do you think Rust export C++ linkage? Rust support [two mangling version](https://doc.rust-lang.org/rustc/symbol-mangling/index.html#mangling-versions) :

Re: How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread monkyyy via Digitalmars-d-learn
On Friday, 4 October 2024 at 08:45:49 UTC, holyzantaclara wrote: Is there a way to achieve this? dub concerns ctfe risky whats this fud about? Will try to generate a .d file that would contain a static D object instead and then compile this .d file. While ctfe json is bad, you should st

Re: How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 4 October 2024 at 08:45:49 UTC, holyzantaclara wrote: Hello hello everyone ^_^, I am new in D, and started this morning. I found a way to read a file at compile time with `-J.` and `static string content = import("my_json_file.json")` https://dlang.org/spec/expression.html#impor

Re: Wrapper for PAM

2024-10-04 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 4 October 2024 at 12:39:45 UTC, Alexander Zhirov wrote: On Thursday, 3 October 2024 at 23:56:37 UTC, Salih Dincer wrote I meant taking the function to D for the elements of the C syntax. To get only an API to which we can pass our callback, and hide everything else inside the wrappe

Re: Wrapper for PAM

2024-10-04 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 3 October 2024 at 23:56:37 UTC, Salih Dincer wrote I meant taking the function to D for the elements of the C syntax. To get only an API to which we can pass our callback, and hide everything else inside the wrapper. I have no experience porting from C to D, but I would like to tr

Re: How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread holyzantaclara via Digitalmars-d-learn
Thank you everyone, true the compilation speed with the `static immutable string s` is unbearable for my workflow right now. Will try to generate a `.d` file that would contain a static D object instead and then compile this `.d` file.

Re: How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread Dennis via Digitalmars-d-learn
On Friday, 4 October 2024 at 08:45:49 UTC, holyzantaclara wrote: I am new in D, and started this morning. I found a way to read a file at compile time with `-J.` and `static string content = import("my_json_file.json")` static usually means "give this declaration the same semantics as if it w

Re: How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 4 October 2024 at 10:33:37 UTC, Ferhat Kurtulmuş wrote: On Friday, 4 October 2024 at 08:45:49 UTC, holyzantaclara wrote: [...] Your issue is related to static that seems it does not trigger a compile time evaluation. According to the docs, static does not imply immutability at a

Re: How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 4 October 2024 at 08:45:49 UTC, holyzantaclara wrote: Hello hello everyone ^_^, I am new in D, and started this morning. I found a way to read a file at compile time with `-J.` and `static string content = import("my_json_file.json")` But then tried to statically evaluate with `st

Re: How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 4 October 2024 at 08:45:49 UTC, holyzantaclara wrote: Hello hello everyone ^_^, I am new in D, and started this morning. I found a way to read a file at compile time with `-J.` and `static string content = import("my_json_file.json")` But then tried to statically evaluate with `st

How to evaluate a JSON file at compile time and create a struct out of it?

2024-10-04 Thread holyzantaclara via Digitalmars-d-learn
Hello hello everyone ^_^, I am new in D, and started this morning. I found a way to read a file at compile time with `-J.` and `static string content = import("my_json_file.json")` But then tried to statically evaluate with `static JSONValue j = parseJson(content)` but it fails. ```sh main

Re: Wrapper for PAM

2024-10-03 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 3 October 2024 at 22:54:53 UTC, Alexander Zhirov wrote: I want to try to make access via D to PAM. ```d /// I added it here: import pam_wrapper; int main(string[] args) { if (args.length < 3) { writeln("Usage: ", args[0], " "); return 1; } /// I added it h

Wrapper for PAM

2024-10-03 Thread Alexander Zhirov via Digitalmars-d-learn
I want to try to make access via D to PAM. I'm trying to write basic things. I would like to know how to best transform access to callback functions? For example, so that there is no need to cast to a type and use binding to `extern`, move all this to a library? ```d extern(C): struct pam_me

Re: Hello dears, where I can deploy my vibe-d project? Someone know any hosting?

2024-10-03 Thread matheus via Digitalmars-d-learn
On Thursday, 3 October 2024 at 08:51:12 UTC, Danic wrote: I want to know where publish mi D web Look for Adam D. Ruppe on D IRC Channel, he used to deploy some D web apps, he may help you. Matheus.

Re: Hello dears, where I can deploy my vibe-d project? Someone know any hosting?

2024-10-03 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 3 October 2024 at 08:51:12 UTC, Danic wrote: I want to know where publish mi D web You didn't say what platform you were comfortable operating. For Linux, I've often used Debian on a Linode nano instance. $5/month, and with an efficient app, by the time you outgrow it, you can

Re: Hello dears, where I can deploy my vibe-d project? Someone know any hosting?

2024-10-03 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 3 October 2024 at 08:51:12 UTC, Danic wrote: I want to know where publish mi D web You can try Railway or Heroku for example. Or if you like Azure you could host it there as well. I've used Azure before and it's quite easy imo.

Re: Hello dears, where I can deploy my vibe-d project? Someone know any hosting?

2024-10-03 Thread Serg Gini via Digitalmars-d-learn
On Thursday, 3 October 2024 at 08:51:12 UTC, Danic wrote: I want to know where publish mi D web I think any hosting that supports binary deployment

Genuine copy of an element from an associative array

2024-10-03 Thread Holzofen via Digitalmars-d-learn
This is my (feeble) source code, for testing purposes only: uint64 sod_decompose(const uint64 n, const uint64 mod, const ref uint64[] primes, const ref uint64[uint64][uint64] factorials) { auto result = factorials[n]; for (uint64 k = 2; k < n - 1; k++) { aut

Re: Templates considered impressive

2024-10-02 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 1 October 2024 at 17:30:20 UTC, H. S. Teoh wrote: On Tue, Oct 01, 2024 at 04:30:27PM +, Salih Dincer wrote: Please add this to your MyCon structure: ```d alias value this; // assert(num1 == 3.14); ``` And test it like this too, I think it's awesome! [...] IMO it's not a good id

Re: Templates considered impressive

2024-10-01 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 01, 2024 at 04:30:27PM +, Salih Dincer via Digitalmars-d-learn wrote: [...] > > ``` > Please add this to your MyCon structure: > ```d > alias value this; > // assert(num1 == 3.14); > ``` > And test it like this too, I think it's awesome! [...]

Re: Templates considered impressive

2024-10-01 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 1 October 2024 at 16:18:17 UTC, Salih Dincer wrote: ```d // ... struct MyCon { string input; T value; this(string data) { // ... } // ... } } ``` Please add this to your MyCon structure: ```d alias value this; // assert(num1 == 3

Re: Templates considered impressive

2024-10-01 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 1 October 2024 at 01:00:08 UTC, Andy Valencia wrote: ... A conversion like: auto d = atoi!double("123.456"); is about 4k of code. Nice! Congratulations on your initiative. D is very flexible with templates, especially with the mixin templates. For example, you might like t

Re: Templates considered impressive

2024-10-01 Thread Andy Valencia via Digitalmars-d-learn
On Tuesday, 1 October 2024 at 11:45:35 UTC, monkyyy wrote: On Tuesday, 1 October 2024 at 05:44:16 UTC, H. S. Teoh wrote: why spend the time and effort when you could have just done: ``` import std.conv; theres a bunch of relivent tradeoffs and phoboes doesnt make a good set of them To be f

Re: Templates considered impressive

2024-10-01 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 1 October 2024 at 05:44:16 UTC, H. S. Teoh wrote: why spend the time and effort when you could have just done: ``` import std.conv; theres a bunch of relivent tradeoffs and phoboes doesnt make a good set of them

Re: Templates considered impressive

2024-10-01 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 01, 2024 at 01:00:08AM +, Andy Valencia via Digitalmars-d-learn wrote: > I had an old atoi() I wrote when I was getting started with D. You know, > fixed type, string in, int output. Today for fun I templated the type: > > T atoi(T)(string s) [...] It's all go

Re: Adapting foreign iterators to D ranges

2024-09-30 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 25 April 2024 at 03:18:36 UTC, cc wrote: On Wednesday, 24 April 2024 at 05:08:25 UTC, Salih Dincer wrote: Yes, `opApply()` works! You just need to use `do while()` instead of `while()` because it skips the first item. It depends on the type of structure being consumed, if it prov

Re: What exactly the --allinst compiler flag does.

2024-09-28 Thread realhet via Digitalmars-d-learn
Thank You! I just did a test, I did not used the --allinst flag for the first time since 4-5 years. It was a superstition since that, because back then it fixed something. Now to my surprise the test build was successful :D 80KLOC, 20 modules -> 20 obj files, and the full compiling time went

Re: Best practices for class instance variables as parameters

2024-09-28 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Sep 28, 2024 at 06:16:55PM +, Ian via Digitalmars-d-learn wrote: > Hi, > > I'm coming from C and some C++ so the way D stores class instance > variables is new to me. If I'm not mistaken the basic unadorned > instance variable is like a "hidden&qu

Re: Best practices for class instance variables as parameters

2024-09-28 Thread Andy Valencia via Digitalmars-d-learn
On Saturday, 28 September 2024 at 18:16:55 UTC, Ian wrote: Hi, I'm coming from C and some C++ so the way D stores class instance variables is new to me. If I'm not mistaken the basic unadorned instance variable is like a "hidden" pointer. So, when passing class instance variables to a functio

Best practices for class instance variables as parameters

2024-09-28 Thread Ian via Digitalmars-d-learn
Hi, I'm coming from C and some C++ so the way D stores class instance variables is new to me. If I'm not mistaken the basic unadorned instance variable is like a "hidden" pointer. So, when passing class instance variables to a function, what would be the point of passing a pointer or ref? I

Re: What exactly the --allinst compiler flag does.

2024-09-28 Thread user1234 via Digitalmars-d-learn
On Saturday, 28 September 2024 at 12:20:43 UTC, realhet wrote: Hi, I have some statements in my mind about --allinst, but I'm not sure they are correct or not. 1. Normally the compiler analyzes the full code with all the modules, and it only compiles code for template things that are used i

What exactly the --allinst compiler flag does.

2024-09-28 Thread realhet via Digitalmars-d-learn
Hi, I have some statements in my mind about --allinst, but I'm not sure they are correct or not. 1. Normally the compiler analyzes the full code with all the modules, and it only compiles code for template things that are used in the given code. 2. It is not needed for compiling the code w

Re: need help to redefine packed c struct in d

2024-09-28 Thread Dakota via Digitalmars-d-learn
On Saturday, 28 September 2024 at 08:35:39 UTC, Johan wrote: On Saturday, 28 September 2024 at 07:54:40 UTC, Dakota wrote: ```c struct __attribute__((packed)) type1 { uint32_tu32; uint8_t u8; uint16_tu16a; uint16_tu16b; uint8_t u8a;

Re: need help to redefine packed c struct in d

2024-09-28 Thread Johan via Digitalmars-d-learn
On Saturday, 28 September 2024 at 07:54:40 UTC, Dakota wrote: ```c struct __attribute__((packed)) type1 { uint32_tu32; uint8_t u8; uint16_tu16a; uint16_tu16b; uint8_t u8a; uint8_t arr[14]; }; ``` the struct size in C is 24:

Perfect: using foreach with more...

2024-09-27 Thread Salih Dincer via Digitalmars-d-learn
😁 Try the 2nd usage, D is a very flexible language; moves towards perfection! ```d struct Sarma { int i; // mixin DownRange; } struct Foo(T) { int[] array;                       // 1. USAGE    auto opApply(scope int delegate(T) dg) { foreach (ref e; array) {

Re: Integer precision of function return types

2024-09-27 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 27 September 2024 at 20:28:21 UTC, H. S. Teoh wrote: ... The reason for (2) is that in UFCS chains, the only thing you really only care about is what kind of range it is that you're dealing with, and maybe the element type. What exactly the container type is, is unimportant, and in

Re: Integer precision of function return types

2024-09-27 Thread thinkunix via Digitalmars-d-learn
Jonathan M Davis via Digitalmars-d-learn wrote: Well, I don't think that auto is a particularly controversial topic among D programmers... Thank you Jonathan for that very detailed response. This thread can end now unless others really feel the need to comment. I got two outstanding resp

Re: Integer precision of function return types

2024-09-27 Thread thinkunix via Digitalmars-d-learn
H. S. Teoh via Digitalmars-d-learn wrote: In idiomatic D, you'd use `auto` when either (1) you don't care what the type is, you just want whatever value you get to be shoved into a variable, or (2) you *shouldn't* care what the type is, because your code shouldn't be dependi

Re: Integer precision of function return types

2024-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 27, 2024 2:13:45 PM MDT thinkunix via Digitalmars-d-learn wrote: > monkyyy via Digitalmars-d-learn wrote: > > On Friday, 27 September 2024 at 04:23:32 UTC, thinkunix wrote: > >> What about using 'auto' as the return type? > >>

Re: Integer precision of function return types

2024-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 26, 2024 12:53:12 AM MDT Per Nordlöw via Digitalmars-d- learn wrote: > Should a function like > > ```d > uint parseHex(in char ch) pure nothrow @safe @nogc { > switch (ch) { > case '0': .. case '9': > return ch - '0&

Re: Integer precision of function return types

2024-09-27 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 27, 2024 at 04:13:45PM -0400, thinkunix via Digitalmars-d-learn wrote: [...] > I've seen a lot of "use auto everywhere" especially in C++ and was > wondering where the D community stands on it's use. Is it generally > favored or not? > > Personall

Re: Integer precision of function return types

2024-09-27 Thread thinkunix via Digitalmars-d-learn
monkyyy via Digitalmars-d-learn wrote: On Friday, 27 September 2024 at 04:23:32 UTC, thinkunix wrote: What about using 'auto' as the return type? I tried it and it seemed to work OK. Wondering if there are any good reasons to use auto, or bad reasons why not to use auto here?

Re: Integer precision of function return types

2024-09-26 Thread monkyyy via Digitalmars-d-learn
On Friday, 27 September 2024 at 04:23:32 UTC, thinkunix wrote: What about using 'auto' as the return type? I tried it and it seemed to work OK. Wondering if there are any good reasons to use auto, or bad reasons why not to use auto here? You have started a style debate that will last a week,

Re: Integer precision of function return types

2024-09-26 Thread thinkunix via Digitalmars-d-learn
Per Nordlöw via Digitalmars-d-learn wrote: Should a function like ```d uint parseHex(in char ch) pure nothrow @safe @nogc { switch (ch) { case '0': .. case '9':     return ch - '0'; case 'a': .. case 'f':  

Re: Integer precision of function return types

2024-09-26 Thread Quirin Schroll via Digitalmars-d-learn
On Thursday, 26 September 2024 at 06:53:12 UTC, Per Nordlöw wrote: Should a function like ```d uint parseHex(in char ch) pure nothrow @safe @nogc { switch (ch) { case '0': .. case '9': return ch - '0'; case 'a': .. case 'f': return 10 + ch

Re: Integer precision of function return types

2024-09-26 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 26 September 2024 at 06:53:12 UTC, Per Nordlöw wrote: Should a function like ```d uint parseHex(in char ch) pure nothrow @safe @nogc { switch (ch) { case '0': .. case '9': return ch - '0'; case 'a': .. case 'f': return 10 + ch

Re: Integer precision of function return types

2024-09-26 Thread user1234 via Digitalmars-d-learn
On Thursday, 26 September 2024 at 06:53:12 UTC, Per Nordlöw wrote: Should a function like ```d uint parseHex(in char ch) pure nothrow @safe @nogc { switch (ch) { case '0': .. case '9': return ch - '0'; case 'a': .. case 'f': return 10 + ch

Re: Integer precision of function return types

2024-09-26 Thread monkyyy via Digitalmars-d-learn
On Thursday, 26 September 2024 at 06:53:12 UTC, Per Nordlöw wrote: Should a function like ```d uint parseHex(in char ch) pure nothrow @safe @nogc { switch (ch) { case '0': .. case '9': return ch - '0'; case 'a': .. case 'f': return 10 + ch

Re: mod of negative number

2024-09-24 Thread Timon Gehr via Digitalmars-d-learn
On 9/23/24 21:52, Craig Dillabaugh wrote: Why does the following program:     \     import std.stdio;     int main(string[] args) {     uint Q = 7681;     writeln("Val = ", -1 % Q);     return 0;     }     \     Print     Val = 5568 Was hopin

Split by top level comma

2024-09-24 Thread monkyyy via Digitalmars-d-learn
I *strongly* believe the answer is not reasonable using phoboes tools; but Im going to leave it as an open question before I get started on something from scratch. Given well compliant phoboes-style ranges and a `ref string or retro!string` that starts with '(',')','[',']','{','}', modify tha

Re: mod of negative number

2024-09-24 Thread Sergey via Digitalmars-d-learn
On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: \ import std.stdio; int main(string[] args) { uint Q = 7681; writeln("Val = ", -1 % Q); return 0; } \ Print Val

Re: mod of negative number

2024-09-23 Thread Craig Dillabaugh via Digitalmars-d-learn
On Monday, 23 September 2024 at 20:02:25 UTC, Craig Dillabaugh wrote: On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: snip Opps, sorry. I was expecting 7680 (not -1 or 5568). After a bit of research I see this is the same behavior as C,

Re: mod of negative number

2024-09-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 23, 2024 1:52:02 PM MDT Craig Dillabaugh via Digitalmars- d-learn wrote: > Why does the following program: > > \ > import std.stdio; > > int main(string[] args) { > uint Q = 7681; >

Re: mod of negative number

2024-09-23 Thread Craig Dillabaugh via Digitalmars-d-learn
On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: \ import std.stdio; int main(string[] args) { uint Q = 7681; writeln("Val = ", -1 % Q); return 0; } \ Print Val

Re: need help to work around float union non-zero init

2024-09-23 Thread Dakota via Digitalmars-d-learn
On Friday, 20 September 2024 at 16:21:10 UTC, Nick Treleaven wrote: On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: Thanks to Dennis for the workaround. Thanks your all for the tips, void solution fix me problem.

Re: Easy way for FFI

2024-09-22 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 23/09/2024 10:13 AM, Maximilian Naderer wrote: I want to create a .h file from my D modules so you’re saying this should be also possible ? There is support in the compiler, but its not really mature. https://dlang.org/dmd-windows.html#switch-HC[

Re: Easy way for FFI

2024-09-22 Thread Maximilian Naderer via Digitalmars-d-learn
Hello Richard, Thank you for the info. I thought this goes the other way around. Using a header file and converting it to a .di file. I want to create a .h file from my D modules so you’re saying this should be also possible ?

Re: Easy way for FFI

2024-09-22 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There are a number of solutions for C bindings creation. Try ImportC its built into the compiler. You can use the .di generator to emit a D file for further use and manual cleanup. https://dlang.org/spec/importc.html It does depend upon the system toolchain, so you'll want MSVC installed if

Easy way for FFI

2024-09-22 Thread Maximilian Naderer via Digitalmars-d-learn
Hello, so what are my / our best options to create an automatic C foreign function interface. I would like to create such interface / header file from a D module with public functions, structs which are declared with extern(C) D code module leo extern(C) void test() { } Expectation: //

Re: Gtkd questions

2024-09-22 Thread Dejan Lekic via Digitalmars-d-learn
On Sunday, 22 September 2024 at 15:44:17 UTC, Ian wrote: Ron Tarrant for gtkcoding.com by the way!) Is there a place where I can ask specific Gtkd questions? I came across some For many years this has been the main place to ask GtkD-related questions: https://forum.gtkd.org/groups/GtkD/

Gtkd questions

2024-09-22 Thread Ian via Digitalmars-d-learn
Hi, I have started using Gtkd for my first D app. (Many thanks to Ron Tarrant for gtkcoding.com by the way!) Is there a place where I can ask specific Gtkd questions? I came across some post at some point mentioning they may have another forum but I don't remember it now. Cheers, Ian

Re: How to escape control characters?

2024-09-22 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 19 September 2024 at 14:30:08 UTC, Gerardo Cahn wrote: On Wednesday, 24 August 2022 at 08:12:33 UTC, Salih Dincer wrote: On Tuesday, 23 August 2022 at 23:17:21 UTC, Salih Dincer wrote: ... Actually, both structures could be combined: ```d struct EscapedString { string[1] str;

Re: Poor Carlos does not manage to find where to eat

2024-09-22 Thread IchorDev via Digitalmars-d-learn
On Saturday, 21 September 2024 at 05:00:51 UTC, user1234 wrote: On Saturday, 21 September 2024 at 04:29:15 UTC, user1234 wrote: ```d module m; [...] Beside the childish example... D could use a system of "constraint matching score" to help Carlos. Three AndAndExps verified should have a bet

Re: Poor Carlos does not manage to find where to eat

2024-09-20 Thread user1234 via Digitalmars-d-learn
On Saturday, 21 September 2024 at 04:29:15 UTC, user1234 wrote: ```d module m; [...] Beside the childish example... D could use a system of "constraint matching score" to help Carlos. Three AndAndExps verified should have a better score than two and finally determine the selection.

Re: need help to work around float union non-zero init

2024-09-20 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32;

Re: need help to work around float union non-zero init

2024-09-20 Thread monkyyy via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32;

Re: How to escape control characters?

2024-09-20 Thread kdevel via Digitalmars-d-learn
On Thursday, 19 September 2024 at 14:30:08 UTC, Gerardo Cahn wrote: I am using the code listed here. It should be left to posterity that the code presented in this thread cannot properly escape ``` "A\xfeZ" ``` ``` BV's escape: cast(char) 0x41, cast(char) 0xFE, cast(char) 0x5A steve's: c

Re: need help to work around float union non-zero init

2024-09-20 Thread IchorDev via Digitalmars-d-learn
On Friday, 20 September 2024 at 09:38:54 UTC, Dakota wrote: I consider this is compiler bug (it may take years to get fixed) I've sent issues for compiler bugs and had them fixed within the next release—about month, not years. Also yes, this seems to be a compiler bug; unless there's some s

need help to work around float union non-zero init

2024-09-20 Thread Dakota via Digitalmars-d-learn
I need my struct defined as `isZeroInit`, so can I can import them as `di` file. (this also reduce build size) But I find this problem with float inside union: ```d struct test_t { union { int i32; float f32; } } static assert(__traits(isZeroInit, test_t) ); ``` ``

Re: How to escape control characters?

2024-09-19 Thread Gerardo Cahn via Digitalmars-d-learn
On Wednesday, 24 August 2022 at 08:12:33 UTC, Salih Dincer wrote: On Tuesday, 23 August 2022 at 23:17:21 UTC, Salih Dincer wrote: ... Actually, both structures could be combined: ```d struct EscapedString { string[1] str; this(string str) @nogc pure nothrow @safe { ...(rest clipped) `

Using C header libs with importC

2024-09-18 Thread Imperatorn via Digitalmars-d-learn
https://forum.dlang.org/post/qpmqvhipfyyyehvoe...@forum.dlang.org On Monday, 8 January 2024 at 23:00:02 UTC, Dennis wrote: On Monday, 8 January 2024 at 21:56:10 UTC, Renato wrote: but I tried exactly that! Which gives a seg fault. Looks like there's a bug with the -H switch: https://issues.dl

Re: vibe-d linker error: undefined reference to deimos openssl

2024-09-16 Thread Curtis Spencer via Digitalmars-d-learn
On Saturday, 14 September 2024 at 12:31:01 UTC, Steven Schveighoffer wrote: On Tuesday, 10 September 2024 at 20:41:12 UTC, Curtis Spencer wrote: I'm attempting to upgrade the vibe-d dependencies of a project. The project compiles fine using `dub`, but the linker fails with: … I'm at a loss

Re: vibe-d linker error: undefined reference to deimos openssl

2024-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 10 September 2024 at 20:41:12 UTC, Curtis Spencer wrote: I'm attempting to upgrade the vibe-d dependencies of a project. The project compiles fine using `dub`, but the linker fails with: … I'm at a loss for how to fix this linker error. Any help would be appreciated. You may

Re: assert

2024-09-12 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 12 September 2024 at 22:34:04 UTC, user1234 wrote: On Wednesday, 11 September 2024 at 10:08:29 UTC, ryuukk_ wrote: On Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote: On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote: [...] I again apologies for bei

Re: assert

2024-09-12 Thread user1234 via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 10:08:29 UTC, ryuukk_ wrote: On Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote: On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote: [...] I again apologies for being wrong and i apologies again for trying to improve things, i d

Re: Is it possible to use templates to implement something like the `@show` macro from the Julia programming langauge in D?

2024-09-12 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 22:06:54 UTC, WB wrote: Honestly, D, does not really need it, and most of solutions (like above) do have one or few limitations and drawbacks. Some will be acceptable in some projects, some not. There is plenty of stuff in language and library already, add

Re: assert

2024-09-12 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 04:01:53 UTC, f wrote: i mean , is this a bug? This is not a bug. The problem is due to a misunderstanding of the -release parameter. The following related topic opened by Steven and the answers given by Walter are really valuable: https://forum.dlang.org/t

Re: assert

2024-09-11 Thread Fox via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 16:40:05 UTC, Bradley Chatha wrote: On Wednesday, 11 September 2024 at 12:17:02 UTC, Fox wrote: I don't care about whether it's a bug or not, I just want to learn What illegal instructions did this "assert(false);" code create? Fortunately Godbolt supports

Re: Is it possible to use templates to implement something like the `@show` macro from the Julia programming langauge in D?

2024-09-11 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 22:06:54 UTC, WB wrote: I feel there is too much already in D and standard library, and things are added to quickly and eagerly, and years later we end up in a mess that cannot be solved (because of compatibility). this isnt autodecoding, cant be, your oping

Re: Is it possible to use templates to implement something like the `@show` macro from the Julia programming langauge in D?

2024-09-11 Thread WB via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 19:44:54 UTC, Salih Dincer wrote: It looks clean and understandable. What is not understandable is that it has not been included in std.stdio for over 10 years. I know, string interpolation has just been integrated, but why hasn't something like this been deve

Re: Is it possible to use templates to implement something like the `@show` macro from the Julia programming langauge in D?

2024-09-11 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 18:29:39 UTC, WB wrote: This code is about 13 years old, but still works. (It is functional and works, but I never it used more than what is in this repo). But now that we have interpolation sequences in the language, it would be way easier, cleaner and more

Re: Is it possible to use templates to implement something like the `@show` macro from the Julia programming langauge in D?

2024-09-11 Thread WB via Digitalmars-d-learn
On Sunday, 8 September 2024 at 22:01:10 UTC, WraithGlade wrote: Specifically, I want a way to create a print command that behaves like `@show` from Julia lang or `dump` from (if my memory is correct) Nim. Yes. https://github.com/baryluk/echo/blob/master/echo.d#L205-L209 ```d mixin(echo("e

Re: assert

2024-09-11 Thread Bradley Chatha via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 12:17:02 UTC, Fox wrote: I don't care about whether it's a bug or not, I just want to learn What illegal instructions did this "assert(false);" code create? Fortunately Godbolt supports D, so it's easy to see that it generates `ud2` on x86(_64): https://god

Re: assert

2024-09-11 Thread Fox via Digitalmars-d-learn
I don't care about whether it's a bug or not, I just want to learn What illegal instructions did this "assert(false);" code create?

Re: assert

2024-09-11 Thread Kapendev via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 10:08:29 UTC, ryuukk_ wrote: On Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote: On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote: It is a bug, don't claim it is not, the compiler gives the wrong information, wich lead to a con

Re: assert

2024-09-11 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote: On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote: It is a bug, don't claim it is not, the compiler gives the wrong information, wich lead to a confused user You don't want confused users, you want compiler say

Re: assert

2024-09-11 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote: It is a bug, don't claim it is not, the compiler gives the wrong information, wich lead to a confused user You don't want confused users, you want compiler say what's up, if i type assert, it should assert, end of the story The

Re: assert

2024-09-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 10, 2024 10:01:53 PM MDT f via Digitalmars-d-learn wrote: > i mean , is this a bug? No, it's not a bug. Assertions with an expression that is known to be false at compile time are treated as special. They are always left in the generated code so that they will k

Re: assert

2024-09-10 Thread f via Digitalmars-d-learn
i mean , is this a bug?

assert

2024-09-10 Thread f via Digitalmars-d-learn
void main() { assert(false); } dmd -release a.d dmd version 2.109.1 debian bookworm x64 illegal instruction thanks

vibe-d linker error: undefined reference to deimos openssl

2024-09-10 Thread Curtis Spencer via Digitalmars-d-learn
I'm attempting to upgrade the vibe-d dependencies of a project. The project compiles fine using `dub`, but the linker fails with: ``` /usr/bin/ld: ../../.dub/packages/vibe-d-0.9.8/vibe-d/tls/.dub/build/openssl-debug-linux.posix-x86_64-dmd_v2.101.2-BCC9E2A9CB402B67930FAFFBF7360088035232BADBED8A5

Re: Can the send function send an array?

2024-09-10 Thread Fox via Digitalmars-d-learn
OK, It works, thanks. // dlang tries to use the type system to make one be clear about what data is shared between potentially concurrent threads. // You need that data to be "shared" before you can send it between threads. // Andy import std.concurrency; import std.stdio; void main(){

Re: Can the send function send an array?

2024-09-10 Thread Andy Valencia via Digitalmars-d-learn
On Tuesday, 10 September 2024 at 13:14:05 UTC, Fox wrote: // I am learning how to send and receive data. The following is my intention, but it cannot be compiled. // aliases to mutable thread-local data not allowed, what does it mean? thank you. dlang tries to use the type system to make one b

Can the send function send an array?

2024-09-10 Thread Fox via Digitalmars-d-learn
// I am learning how to send and receive data. The following is my intention, but it cannot be compiled. // aliases to mutable thread-local data not allowed, what does it mean? thank you. I am learning how to send and receive. The following is my intention, but it cannot be compiled. Report i

<    1   2   3   4   5   6   7   8   9   10   >