Re: ImportC issue?

2023-04-19 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 19 April 2023 at 13:11:45 UTC, DLearner wrote: On Wednesday, 19 April 2023 at 12:09:44 UTC, Richard (Rikki) Andrew Cattermole wrote: On 20/04/2023 12:07 AM, DLearner wrote: Error: C preprocess command sppn.exe failed for file ex01.c, exit status 1 Did you verify that sppn is

Re: ImportC issue?

2023-04-19 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 19 April 2023 at 10:21:22 UTC, DLearner wrote: C source ex01.c: ``` #include int main() { printf("hello world\n"); return 0; } ``` 'dmc ex01.c' produces message: ``` link ex01,,,user32+kernel32/noi; ``` but does generate .obj, .map and .exe files, and the exe executes

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-03-31 Thread bachmeier via Digitalmars-d-learn
On Friday, 31 March 2023 at 16:26:36 UTC, ryuukk_ wrote: I disagree, global mutables are not bad That the same bad advice as telling people to "embrace OOP and multiple inheritance" and all the Java BS "just put your variable into a class and make it static, and then have your singleton to

Re: Implicit type conversion depending on assignment

2023-03-24 Thread bachmeier via Digitalmars-d-learn
On Friday, 24 March 2023 at 13:53:02 UTC, bachmeier wrote: On Thursday, 23 March 2023 at 13:38:51 UTC, Alexander Zhirov wrote: Is it possible to convert such records inside the structure to the assigned type? ```d struct MyVal { string value; // Here it would be possible to use an

Re: Implicit type conversion depending on assignment

2023-03-24 Thread bachmeier via Digitalmars-d-learn
On Thursday, 23 March 2023 at 13:38:51 UTC, Alexander Zhirov wrote: Is it possible to convert such records inside the structure to the assigned type? ```d struct MyVal { string value; // Here it would be possible to use an alias to this, but it can only be used 1 time } auto a =

Re: stdin.readln line editing and recall with up arrow

2023-02-25 Thread bachmeier via Digitalmars-d-learn
On Saturday, 25 February 2023 at 08:45:27 UTC, Daren Scot Wilson wrote: On Saturday, 25 February 2023 at 05:41:48 UTC, Richard (Rikki) Andrew Cattermole wrote: On 25/02/2023 6:36 PM, Daren Scot Wilson wrote: stdin.readln() works fine until I, out of habit, use the up arrow to recall an earlier

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-16 Thread bachmeier via Digitalmars-d-learn
On Thursday, 16 February 2023 at 21:23:53 UTC, ProtectAndHide wrote: Forcing programmers to use a design mechanism rather than a language mechanism to achieve the above abstraction is wrong. This seems to be the source of the disagreement, correct? There's no disagreement. It's you posting

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 07:13:41 UTC, thebluepandabear wrote: Time to move on to OCaml programmers telling us D doesn't have floating point arithmetic because there's no `+.` operator. that's not the same thing though, you've created a great false equivalence! Congrats. Only if

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 19:44:50 UTC, ProtectAndHide wrote: A user-defined type is a type that has a mechanism to keep it representation private. D does not support this. It only enables it. You (and others) may well argue that D should not enable this (directly), it should only

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-14 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 02:14:30 UTC, Mike Parker wrote: On Wednesday, 15 February 2023 at 01:16:00 UTC, thebluepandabear wrote: I think what you could say is that D lacks _encapsulation_ which is also an OOP concept. So D is partially OOP but not fully OOP due to there being no

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-14 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 14 February 2023 at 10:16:47 UTC, ProtectAndHide wrote: In any case, there is nothing 'picky' about wanting to be able to explicately 'declare' a member of my class type as being private. That to me, is what a programmer should expect to be able to do in a language that says it

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-10 Thread bachmeier via Digitalmars-d-learn
On Friday, 10 February 2023 at 07:04:31 UTC, Max Samukha wrote: Having class-private doesn't preclude module-private. Dennis even submitted a PR implementing class-private, but it stalled because people couldn't agree on whether class-private should be "private to class" or "private to class

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread bachmeier via Digitalmars-d-learn
On Friday, 10 February 2023 at 00:18:59 UTC, Ali Çehreli wrote: On 2/9/23 15:58, thebluepandabear wrote: >> In contrast, I use D every day and love its relaxed attitude towards >> private. > > the fact that private stuff is accessible from other classes in the same > module is really really bad,

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread bachmeier via Digitalmars-d-learn
On Thursday, 9 February 2023 at 23:51:18 UTC, thebluepandabear wrote: btw. When a newbie to D raises ideas, suggestions, etc... and you counter them with (in essence) 'we don't need that in D, but go write a dip if you think we do' attitude, is a real turn off. yeah it seems like the

Re: ImportC "no include path set"

2023-02-09 Thread bachmeier via Digitalmars-d-learn
On Thursday, 9 February 2023 at 06:07:35 UTC, Elfstone wrote: Maybe Walter doesn't care about Windows enough, but I thought it'd be a must to add basic tests (say, "dmd hello.c") to run on all the platforms before release. Unlikely, since his text editor [doesn't even compile on

Re: ImportC "no include path set"

2023-02-08 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 06:49:06 UTC, Elfstone wrote: I believe all three versions (2017,2019,2022) of my VS are up to date, and I have working C/C++ projects on them. But you encouraged me to give a few more tries, and I found out I had been using ..bin64/dmd.exe. Running

Re: betterC DLL in Windows

2023-02-06 Thread bachmeier via Digitalmars-d-learn
On Sunday, 5 February 2023 at 08:48:34 UTC, Tamas wrote: I appreciate all of this... however, as a newcomer, I wish the docs were simply more honest, instead of representing wishful thinking. I guess in any programming language, experience reveals things not present in the docs, but it seems

Re: ImportC "no include path set"

2023-02-06 Thread bachmeier via Digitalmars-d-learn
On Monday, 6 February 2023 at 06:55:02 UTC, Elfstone wrote: So how am I supposed to set the include path? https://dlang.org/spec/importc.html#preprocessor The -Ppreprocessorflag switch passes preprocessorflag to the preprocessor. So if you normally use `-I/foo`, you'd add `-P-I/foo`.

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-06 Thread bachmeier via Digitalmars-d-learn
On Sunday, 5 February 2023 at 03:38:04 UTC, thebluepandabear wrote: On Sunday, 5 February 2023 at 03:19:43 UTC, bachmeier wrote: Something of a puzzle that it works with Arch, though, but not Ubuntu/Mint. It doesn't sound like Arch has that problem. What problem doesn't Arch have, the

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread bachmeier via Digitalmars-d-learn
On Saturday, 4 February 2023 at 23:51:17 UTC, thebluepandabear wrote: "Error: Missing Symbol, Message: sfText_getLineSpacing", "Error: Missing Symbol, Message: sfText_getLineSpacing"] source/app.d:19 void app.loadDyn() [0x55d86edd1931] source/app.d:24 _Dmain [0x55d86edd1954]

Re: betterC DLL in Windows

2023-02-04 Thread bachmeier via Digitalmars-d-learn
On Saturday, 4 February 2023 at 18:40:51 UTC, Tamas wrote: It is hopelessly broken, but thankfully, it also brings zero benefit, so simply not using it is a viable path forward. I do take your word for it, but now I have to re-evaluate my expectations towards D and perhaps use it for another

Re: betterC DLL in Windows

2023-02-04 Thread bachmeier via Digitalmars-d-learn
On Saturday, 4 February 2023 at 18:29:41 UTC, Tamas wrote: What's the reason to prefer LDC over DMD? Anyone that cares about performance will use LDC rather than DMD. It's hard to imagine a case where someone would want betterC to avoid the GC, but they wouldn't want to use LDC. When I

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread bachmeier via Digitalmars-d-learn
On Saturday, 4 February 2023 at 05:29:43 UTC, thebluepandabear wrote: I have tested on arch linux and everything works fine, i'll try to setup a linux mint / ubuntu VM tomorrow Thanks. It seems like an issue with my system then. I've been stuck on it for a week or so, but haven't been able

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread bachmeier via Digitalmars-d-learn
On Friday, 3 February 2023 at 12:23:40 UTC, thebluepandabear wrote: On Friday, 3 February 2023 at 11:43:46 UTC, thebluepandabear wrote: On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote: On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear wrote: I recently did a fresh

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread bachmeier via Digitalmars-d-learn
On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear wrote: I recently did a fresh install of CSFML and I am getting this errors when running my csfml D bindings program: ``` object.Exception@source/app.d(38): Fatal error(s) encountered whilst calling `loadSFML()` function: ["Error:

Re: Pyd examples or resources for Python 3.x

2023-01-19 Thread bachmeier via Digitalmars-d-learn
On Friday, 20 January 2023 at 00:39:47 UTC, Seamus wrote: Howdy folks I am new around these parts and looking forward to getting stuck into some D development. Really liking it so far, just one some questions though... I am working on a project that did not sit well with me when I tried it

Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread bachmeier via Digitalmars-d-learn
On Thursday, 19 January 2023 at 04:22:21 UTC, thebluepandabear wrote: Help would be appreciated. Regards, thebluepandabear A bit off topic/ranty but I did find the book by Ali on D extremely useful, but it was good as an 'introduction'. I feel like when it comes to more advanced features

Re: Problem with ImportC example?

2023-01-18 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 18 January 2023 at 16:51:27 UTC, bachmeier wrote: On Wednesday, 18 January 2023 at 16:37:17 UTC, Ali Çehreli wrote: On 1/18/23 08:04, DLearner wrote: > Unfortunately, neither works: > ``` > C:\Users\SoftDev>cl.exe > 'cl.exe' is not recognized as an internal or external >

Re: Problem with ImportC example?

2023-01-18 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 18 January 2023 at 16:37:17 UTC, Ali Çehreli wrote: On 1/18/23 08:04, DLearner wrote: > Unfortunately, neither works: > ``` > C:\Users\SoftDev>cl.exe > 'cl.exe' is not recognized as an internal or external command, > operable program or batch file. That supports the theory that

Re: Problem with ImportC example?

2023-01-17 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote: On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote: On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote: ``` C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c ex01.c(1): Error: C preprocessor directive `#include` is

Re: Coding Challenges - Dlang or Generic

2023-01-10 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 10 January 2023 at 01:22:33 UTC, H. S. Teoh wrote: Here's a challenge. Given an input year, for example, "2023", write a program that outputs (for the corresponding year): snip- 2023

Re: Solving optimization problems with D

2023-01-03 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 3 January 2023 at 21:13:55 UTC, Sergey wrote: On Sunday, 1 January 2023 at 21:11:06 UTC, Ogi wrote: I’ve read this [series if articles](https://www.gamedeveloper.com/design/decision-modeling-and-optimization-in-game-design-part-1-introduction) about using Excel Solver for all kinds

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread bachmeier via Digitalmars-d-learn
On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: Dear dlang community. I am unsure about what idiomatic D is. Idiomatic D code produces the correct result, it's readable, and it's easy for others to use. Some of the Dconf talks tells people just to use the GC, until you can't

Re: Using glibc headers with ImportC

2022-11-12 Thread bachmeier via Digitalmars-d-learn
On Saturday, 12 November 2022 at 15:08:22 UTC, qua wrote: On Saturday, 12 November 2022 at 14:57:23 UTC, Adam D Ruppe wrote: I still don't think that's been released yet, so if you aren't on the git master or at least the latest beta build it isn't going to work. Which dmd version are you

Re: Find in assoc array then iterate

2022-10-22 Thread bachmeier via Digitalmars-d-learn
On Saturday, 22 October 2022 at 04:53:09 UTC, Kevin Bailey wrote: Steven, Just because you don't see the value doesn't mean I don't. You should try to be more helpful, or don't bother. Programs are written to do things that have value. Programming languages are designed to support that

Re: Catching C errors

2022-10-20 Thread bachmeier via Digitalmars-d-learn
On Thursday, 20 October 2022 at 10:13:41 UTC, Sergey wrote: On Thursday, 20 October 2022 at 09:52:05 UTC, data pulverizer wrote: I'm currently writing a D interop with R, the dynamic statistical programming language. There's a function called How is your project related to EmbedR? The

Re: Replacing tango.text.Ascii.isearch

2022-10-07 Thread bachmeier via Digitalmars-d-learn
On Friday, 7 October 2022 at 07:16:19 UTC, Siarhei Siamashka wrote: On Friday, 7 October 2022 at 06:34:50 UTC, Siarhei Siamashka wrote: Also are we allowed to artificially construct needle and haystack to blow up this test rather than only benchmarking it on typical real data? Such as

Re: Recommendation for parallelism with nested for loops?

2022-08-19 Thread bachmeier via Digitalmars-d-learn
On Friday, 19 August 2022 at 02:02:57 UTC, Adam D Ruppe wrote: Even if they aren't equal, you'll get decent benefit from parallel on the outer one alone, but not as good since the work won't be balanced. Unless there's some kind of blocking going on in D's implementation, if the number of

Re: std.algorithm.cmp is conflicting with itself.

2022-08-11 Thread bachmeier via Digitalmars-d-learn
On Thursday, 11 August 2022 at 22:34:11 UTC, realhet wrote: On Thursday, 11 August 2022 at 19:33:31 UTC, bachmeier wrote: std.string does a public import of std.algorithm.cmp. That was it! Thanks! Conclusion: This is how to overload cmp() A search of the forum suggests [this is how I

Re: std.algorithm.cmp is conflicting with itself.

2022-08-11 Thread bachmeier via Digitalmars-d-learn
On Thursday, 11 August 2022 at 18:32:54 UTC, realhet wrote: On Thursday, 11 August 2022 at 18:10:31 UTC, Paul Backus wrote: ... If you remove `std.algorithm` from `testcmpmodule2`'s `public import` line, the code compiles successfully. Yes, but in the 40 module project I'm unable to make it

Re: vectorization of a simple loop -- not in DMD?

2022-07-12 Thread bachmeier via Digitalmars-d-learn
On Monday, 11 July 2022 at 21:46:10 UTC, IGotD- wrote: Just depreciate the the DMD backend, it's just not up to the task anymore. Just deprecate LDC and GDC. They compile slowly and are unlikely to ever deliver fast compile times, due to their design. Some people say they like it because

Re: How to use ImportC?

2022-03-04 Thread bachmeier via Digitalmars-d-learn
On Friday, 4 March 2022 at 17:17:17 UTC, MoonlightSentinel wrote: On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: Thanks but not worked here. ``` [leonardo@leonardo-pc dimportc]$ dmd --version DMD64 D Compiler v2.098.1 ``` Please retry with the

Re: How to use ImportC?

2022-03-03 Thread bachmeier via Digitalmars-d-learn
On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: Thanks but not worked here. ``` [leonardo@leonardo-pc dimportc]$ dmd --version DMD64 D Compiler v2.098.1 Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved written by Walter Bright [leonardo@leonardo-pc

Re: How to use ImportC?

2022-03-03 Thread bachmeier via Digitalmars-d-learn
On Thursday, 3 March 2022 at 19:05:22 UTC, Leonardo wrote: I saw the new feature called ImportC, it's cool to be able to use C code/libraries, but I'm not much experience in C and didn't understand this incomplete documentation: https://dlang.org/spec/importc.html How to use ImportC? You

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread bachmeier via Digitalmars-d-learn
On Thursday, 3 March 2022 at 13:55:47 UTC, BoQsc wrote: On Thursday, 3 March 2022 at 13:25:32 UTC, Stanislav Blinov wrote: On Thursday, 3 March 2022 at 12:14:13 UTC, BoQsc wrote: I need to check if a string contains integers, and if it contains integers, remove all the regular string

Re: Will it be possible to write a GCC frontend in D?

2022-02-23 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 23 February 2022 at 19:58:45 UTC, rempas wrote: I'm using a book called "modern compiler design (version 2)" to learn how to create compiler and I thought about learning and applying this knowledge on writing a GCC frontend just for fun to see where this gets me. However, I've

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 00:44:58 UTC, jmh530 wrote: On Tuesday, 22 February 2022 at 00:36:38 UTC, bachmeier wrote: [snip] Yes. std.random is another. I gave up out on the current one. Luckily I already had external libraries for that before I started using D. Have you tried

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 21 February 2022 at 22:58:17 UTC, Ali Çehreli wrote: On 2/21/22 09:34, bachmeier wrote: > I may have to look for an alternative > JSON library for D. std.json is not the most fun independent of this issue. std.json is a very good module. At work, we had to write additional code to

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 21 February 2022 at 17:50:56 UTC, bachmeier wrote: I looked at the source for `parseJSON` and I see references only to `JSONOptions.strictParsing` and `JSONOptions.specialFloatLiterals`. I may be missing something, but I don't see any option to iterating over every element and

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 21 February 2022 at 17:32:23 UTC, bachmeier wrote: On Monday, 21 February 2022 at 04:02:23 UTC, Steven Schveighoffer wrote: On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote: I tried this ```d import std.json, std.stdio; void main() { writeln(parseJSON(`{"a":

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
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. Escaping slashes as a default is a huge mistake

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 21 February 2022 at 04:02:23 UTC, Steven Schveighoffer wrote: On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote: I tried this ```d import std.json, std.stdio; void main() { writeln(parseJSON(`{"a": "path/file"}`, JSONOptions.doNotEscapeSlashes)); } ``` but the

Is there a way to not escape slashes when parsing JSON?

2022-02-20 Thread bachmeier via Digitalmars-d-learn
I tried this ``` import std.json, std.stdio; void main() { writeln(parseJSON(`{"a": "path/file"}`, JSONOptions.doNotEscapeSlashes)); } ``` but the output is ``` {"a":"path\/file"} ``` Is there a way to avoid the escaping of the forward slash? Is there some reason I should want to

Re: Strange behavior of iota

2022-02-16 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 15:21:11 UTC, jmh530 wrote: On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say that iota's behavior doesn't make much sense. What do you propose

Re: Strange behavior of iota

2022-02-16 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 02:51:32 UTC, Era Scarecrow wrote: On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: On Tuesday, 15 February 2022 at 22:02:13 UTC, Adam D Ruppe wrote: for(a = v.length; a > cast(size_t) -1, a += -1) After looking at the documentation and seeing

Re: Strange behavior of iota

2022-02-15 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 22:02:13 UTC, Adam D Ruppe wrote: On Tuesday, 15 February 2022 at 21:48:29 UTC, bachmeier wrote: writeln(iota(v.length,-1,-1)); This would be like for(a = v.length; a > cast(size_t) -1, a += -1) That (cast(size_t) -1) is the same as thing.max, meaning a

Strange behavior of iota

2022-02-15 Thread bachmeier via Digitalmars-d-learn
This code ``` import std.conv, std.range, std.stdio; void main() { auto v = [1, 2, 3, 4, 5]; writeln(iota(v.length,-1,-1)); writeln(iota(v.length,-1.to!long,-1)); writeln(iota(v.length.to!int,-1,-1)); writeln(iota(v.length.to!uint,-1,-1));

Re: Libc functions undefined when linking

2022-01-04 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 4 January 2022 at 18:13:56 UTC, Ben Jones wrote: be using don't have a D compiler installed (they're Fedora machines, and I didn't see a dmd package in their repos, or I would have asked the admins to install it). Just for the record, while the official Fedora repos don't have

Re: How to insert code in place with templates/mixins?

2021-12-20 Thread bachmeier via Digitalmars-d-learn
On Monday, 20 December 2021 at 18:23:44 UTC, rempas wrote: On Monday, 20 December 2021 at 18:12:35 UTC, Stanislav Blinov wrote: https://dlang.org/spec/traits.html#identifier Thanks!!! Finally I was able to do it! The code is the following (well not in my final project but it's a

Re: ImportC: Should this compile?

2021-12-19 Thread bachmeier via Digitalmars-d-learn
On Sunday, 19 December 2021 at 02:57:35 UTC, Mike Parker wrote: On Saturday, 18 December 2021 at 22:31:38 UTC, bachmeier wrote: I've been trying to get the stb header library to compile. There's a single remaining failure: ``` typedef struct { unsigned char c[4]; } stb_easy_font_color;

ImportC: Should this compile?

2021-12-18 Thread bachmeier via Digitalmars-d-learn
I've been trying to get the stb header library to compile. There's a single remaining failure: ``` typedef struct { unsigned char c[4]; } stb_easy_font_color; stb_easy_font_color c = { 255,255,255,255 }; // use structure copying to avoid needing depending on memcpy() ``` LDC returns ```

Re: Simple text editor program

2021-11-17 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 20:49:22 UTC, Dr Machine Code wrote: On Wednesday, 17 November 2021 at 03:21:34 UTC, Ali Çehreli wrote: On 11/16/21 6:10 PM, pascal111 wrote: Is there a so simple text editor written in D as an example for learners. I hope the editor whose code is written in D

Re: Simple text editor program

2021-11-17 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 21:37:01 UTC, Ali Çehreli wrote: On 11/17/21 12:49 PM, Dr Machine Code wrote: >> I think 'med' is by Walter Bright; he uses that editor daily. >> >> Ali > > It's a emacs' variant written in D? Yes. The dub page explains that the original author is Dave G.

Re: POST request with std.net.curl

2021-07-27 Thread bachmeier via Digitalmars-d-learn
On Monday, 26 July 2021 at 19:53:05 UTC, frame wrote: All better the lib could do is to print the text for the status too and the raw payload sent by the server aka error description, if any. That's what I'm proposing. Currently std.net.curl's post function doesn't report all the

Re: POST request with std.net.curl

2021-07-26 Thread bachmeier via Digitalmars-d-learn
On Sunday, 25 July 2021 at 15:44:14 UTC, frame wrote: On Sunday, 25 July 2021 at 13:07:36 UTC, bachmeier wrote: On Friday, 23 July 2021 at 18:11:51 UTC, bachmeier wrote: [...] After all this, it turned out the answer was a simple (but not obvious) typo in the header information. It would be

Re: POST request with std.net.curl

2021-07-25 Thread bachmeier via Digitalmars-d-learn
On Friday, 23 July 2021 at 18:11:51 UTC, bachmeier wrote: [...] After all this, it turned out the answer was a simple (but not obvious) typo in the header information. It would be nice to get more information than "HTTP request returned status code 400 ()". I don't know if that's possible,

Re: POST request with std.net.curl

2021-07-25 Thread bachmeier via Digitalmars-d-learn
On Saturday, 24 July 2021 at 06:01:25 UTC, frame wrote: On Friday, 23 July 2021 at 21:25:01 UTC, bachmeier wrote: Authorization is working - it's the same whether I'm doing a GET or POST request. The problem is passing the data. The main problem is that the documentation doesn't explain how

Re: POST request with std.net.curl

2021-07-23 Thread bachmeier via Digitalmars-d-learn
On Friday, 23 July 2021 at 19:59:33 UTC, Ali Çehreli wrote: On 7/23/21 11:11 AM, bachmeier wrote: I'm writing a D program that interacts with the Todoist API using std.net.curl. It's not a problem to do get requests to query tasks, but I cannot find a way to get post to work to create a new

POST request with std.net.curl

2021-07-23 Thread bachmeier via Digitalmars-d-learn
I'm writing a D program that interacts with the Todoist API using std.net.curl. It's not a problem to do get requests to query tasks, but I cannot find a way to get post to work to create a new task. This is a working bash script, where APIKEY is defined elsewhere and $1 and $2 are user

Re: How to compile Phobos with other D code to create a shared library?

2021-06-04 Thread bachmeier via Digitalmars-d-learn
On Friday, 4 June 2021 at 15:33:32 UTC, Alain De Vos wrote: Dub is probably not much of a help :) That's right. I typically don't use Dub when I'm calling D functions from R. It's the only way you can use a Dub package like Mir, though, so that's why you might want it to generate a dub.sdl

Re: How to compile Phobos with other D code to create a shared library?

2021-06-04 Thread bachmeier via Digitalmars-d-learn
On Friday, 4 June 2021 at 07:26:53 UTC, data pulverizer wrote: Thanks. Looks like I have some more reading to do. I did know about embedr, but I saw it had dependencies and I wanted a standalone and fully transparent D solution. It requires an R package if you want to call D functions from

Re: How to compile Phobos with other D code to create a shared library?

2021-06-02 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 18:18:35 UTC, data pulverizer wrote: Doing `Runtime.initialize` is working with Julia but not yet R, I'm getting a clock/GLIBC error ``` Error in dyn.load("rbasic.so") : unable to load shared object 'code/rbasic.so': lib/x86_64-linux-gnu/librt.so.1: undefined

Re: dlang vs crystal-language

2021-05-03 Thread bachmeier via Digitalmars-d-learn
On Monday, 3 May 2021 at 12:02:50 UTC, user1234 wrote: I seriously wonder if this is a criterion. For example Gitlab which is known to get updated each month, still uses Ruby in their backend. So their clients use scripts that could be 2x to 20x faster if made in Crystal. I don't think

Re: betterC examples?

2021-04-30 Thread bachmeier via Digitalmars-d-learn
On Friday, 30 April 2021 at 22:22:05 UTC, sfp wrote: I'm developing a C library with Cython bindings, built using CMake. I'd like to use D with -betterC to write some new code where it would be handy to have access to some more advanced language features to keep things readable. For my domain,

Re: Immutable

2021-03-27 Thread bachmeier via Digitalmars-d-learn
On Saturday, 27 March 2021 at 20:44:12 UTC, Brad wrote: I was looking through lots of sample code on Rosetta Code. D has a lot of solutions out there. That is really nice but it has me wondering - coming from other languages that do not support the concept of immutability - do real world

Re: code.dlang.org package search subtly broken?

2021-03-27 Thread bachmeier via Digitalmars-d-learn
On Saturday, 27 March 2021 at 14:53:52 UTC, Imperatorn wrote: Yeah, the search is broken sadly. I made a PR about it some time ago. Partial searches doesn't work I don't think it's Dub search that's broken, really, it's that Dub uses MongoDB for searches, as discussed here:

Re: C++/D class interop example crashes

2021-03-27 Thread bachmeier via Digitalmars-d-learn
On Saturday, 27 March 2021 at 18:39:53 UTC, Bastiaan Veelo wrote: The example links objects statically. You may be experiencing additional challenges with crossing DLL boundaries. I have not yet used DLLs, but did you initialise the D runtime? — Bastiaan. This is an example taken from the

Re: Make foreach element optional

2021-03-16 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 16:29:45 UTC, Imperatorn wrote: On Tuesday, 16 March 2021 at 13:52:29 UTC, Per Nordlöw wrote: On Tuesday, 16 March 2021 at 13:31:34 UTC, Imperatorn wrote: foreach(0..n) could work. Why though. When performing a side-effect n times. Then why not just do: auto

Re: Make foreach element optional

2021-03-16 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 12:49:13 UTC, Per Nordlöw wrote: I find myself writing foreach (_; 0 .. n) doSomething(); // no using the variable `_` . What about relaxing the syntax to allow foreach (; 0 .. n) and/or foreach (0 .. n) ? Thereby making the `ForeachTypeList` of

Re: Vibe.d tutorial

2021-03-01 Thread bachmeier via Digitalmars-d-learn
On Monday, 1 March 2021 at 22:25:39 UTC, Rey Valeza wrote: Hi, I wrote a tutorial on Vibe.d while trying to re-learn Vibe.d. I find that most of Kai Nacke's book need updating, so I wrote a tutorial while trying to re-learn it. Here it is.

Re: Does reserve() preallocate for futher appends too?

2021-03-01 Thread bachmeier via Digitalmars-d-learn
On Monday, 1 March 2021 at 03:07:19 UTC, Jack wrote: isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b = arr[x .. y]? You may potentially find this article of use:

Re: How do I get the output of the time bash command?

2021-01-27 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 09:58:25 UTC, Marcone wrote: On Wednesday, 27 January 2021 at 09:35:21 UTC, Anthony wrote: I'm trying to read the timed output of a pipeShell command but it only results in empty output. Does anyone know why this is? ``` auto p = pipeShell("time ls");

Re: How do I overload += operator?

2021-01-26 Thread bachmeier via Digitalmars-d-learn
On Monday, 25 January 2021 at 17:09:22 UTC, Jack wrote: I'd like to make this work s += 10 where s is a struct. How can I do that? You have your answer, but someone else might come upon this in the future, so here's a link to the clearest explanation of operator overloading for someone new

Re: D Bindings for C Opaque Pointers

2020-12-02 Thread bachmeier via Digitalmars-d-learn
On Thursday, 3 December 2020 at 00:30:06 UTC, Kyle Ingraham wrote: What did I do wrong in constructing the bindings? If it helps the library provides a function called EdsRelease for cleaning-up allocated objects. Is the management of pointers between D and C the issue? Please forgive me if

Re: Reflection on the book D web development.

2020-11-25 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 25 November 2020 at 17:26:44 UTC, Alaindevos wrote: hunt-http has no documentation and does not looks usable to me. What looks usable is kemal & the crystal language, https://kemalcr.com/guide/ Looks like Sinatra. That makes sense given the relationship of Crystal to Ruby. Many

Re: Reflection on the book D web development.

2020-11-23 Thread bachmeier via Digitalmars-d-learn
On Saturday, 21 November 2020 at 16:18:39 UTC, Alaindevos wrote: It's not my related to a lack of knowledge of the d-language but the complexity of the vibe.d framework itself. What I understand are : 1: jade/diet .dt templates, inheritance,includes,markdown. 2: A simple form with POST method.

Re: Question about: ("1.1").to!int;

2020-10-23 Thread bachmeier via Digitalmars-d-learn
On Friday, 23 October 2020 at 13:57:41 UTC, Joseph Rushton Wakeling wrote: In particular, if `to` just accepted any string numerical representation for conversion to int, how could the caller explicitly _exclude_ non-integer input, if that is their use-case? So it's far better to require

Re: More elaborate asserts in unittests?

2020-10-21 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 21 October 2020 at 22:48:04 UTC, IGotD- wrote: On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe wrote: try compiling with dmd -checkaction=context Thanks, that was simple and it worked. Speaking of this, shouldn't this be documented here for example.

Re: Question about: ("1.1").to!int;

2020-10-21 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 21 October 2020 at 22:50:27 UTC, matheus wrote: Since (1.1).to!int = 1, shouldn't the string value ("1.1").to!int at least try to convert to float/double and then to int? I don't think so. A silent string->double conversion isn't IMO consistent with D's design.

Re: Memory management

2020-09-29 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 29 September 2020 at 10:57:07 UTC, novice3 wrote: Naive newbie question: Can we have (in theory) in D lang memory management like V lang? Quote: https://github.com/vlang/v/blob/master/doc/docs.md#memory-management "V doesn't use garbage collection or reference counting. The

Re: Installing D on Fresh Windows 10 machine is a pain

2020-08-27 Thread bachmeier via Digitalmars-d-learn
On Thursday, 27 August 2020 at 16:44:28 UTC, Mike Parker wrote: On Thursday, 27 August 2020 at 16:39:05 UTC, Mike Parker wrote: Or maybe better, just go to the 'Individual components', select the latest Windows 10 SDK version, and install it. Or just check the installation folder. For me,

Re: Creating a pointer array

2020-08-19 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 19 August 2020 at 13:03:54 UTC, data pulverizer wrote: Hi all, How do you create an array of pointers in D? I tried something like ``` double* []y; ``` Or ``` (double*) []y; ``` But I get the error: ``` Error: only one index allowed to index double[] ``` Thanks in advance.

Re: generating random numbers

2020-08-10 Thread bachmeier via Digitalmars-d-learn
On Monday, 10 August 2020 at 14:20:23 UTC, bachmeier wrote: On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote: generating random numbers using https://dlang.org/library/std/random/uniform01.html I find the example given in this section totally incomprehensible .. Can any help me

Re: generating random numbers

2020-08-10 Thread bachmeier via Digitalmars-d-learn
On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote: generating random numbers using https://dlang.org/library/std/random/uniform01.html I find the example given in this section totally incomprehensible .. Can any help me answer two simple questions: How to generate a random floating

Re: dynamic array .length vs .reserve - what's the difference?

2020-07-30 Thread bachmeier via Digitalmars-d-learn
On Thursday, 30 July 2020 at 15:58:28 UTC, wjoe wrote: I just stumbled upon code like this: struct Foo(T) { T[] b; this(int n) { b.reserve(n); b.length = n; } } .reserve looks redundant. The docs are explaining .length nicely, however lack any specifics about

Re: sort a string

2020-05-01 Thread bachmeier via Digitalmars-d-learn
On Friday, 1 May 2020 at 15:04:01 UTC, notna wrote: On Friday, 1 May 2020 at 12:29:26 UTC, Steven Schveighoffer wrote:     dchar[] line3 = sort(line2.to!(dchar[])); dchar[] line3 = sort(line2.to!dchar[]).release; https://dlang.org/phobos/std_range.html#.SortedRange.release hmmm,

Re: Why libmir has to add its own algorithm functions

2020-05-01 Thread bachmeier via Digitalmars-d-learn
On Friday, 1 May 2020 at 11:31:29 UTC, Erdem wrote: As can be seen in the link below : http://mir-algorithm.libmir.org/mir_algorithm_iteration.html Libmir provides almost the same function as std. Why is benefit of doing that? Wouldn't it be better to not duplicate std stuff? Erdem I

Re: How to sum multidimensional arrays?

2020-02-28 Thread bachmeier via Digitalmars-d-learn
On Friday, 28 February 2020 at 16:51:10 UTC, AB wrote: See https://dlang.org/spec/operatoroverloading.html#array-ops for a better overview of the required operators or mir.ndslice for an nD implementation. Here's an old version of some of the things I've been using:

Re: How to sum multidimensional arrays?

2020-02-27 Thread bachmeier via Digitalmars-d-learn
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote: [...] This works but it does not look very efficient considering we flatten and then calling array twice. It will get even worse with 3D arrays. Is there a better way without relying on mir.ndslice? Is there a reason you

Re: Some impressions/notes from a new D programmer

2020-02-12 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote: Library Reference Documentation The Library Reference documentation seems to be a mixed bag. Often I've found a good overview at the start, but then few or no examples in the docs for classes and methods (see e.g.,

  1   2   3   4   >