Re: Debug help - delegate from dlang Tour

2025-09-17 Thread evilrat via Digitalmars-d-learn
On Monday, 8 September 2025 at 14:32:32 UTC, Brother Bill wrote: https://tour.dlang.org/tour/en/basics/delegates This is so simple. What is D complaining about? Should this also work with a Template, as shown? ``` import std.stdio; void main() { // auto add(T)(T lhs, T rhs) //

Re: How to make a slow compile

2025-08-21 Thread evilrat via Digitalmars-d-learn
On Thursday, 21 August 2025 at 13:52:32 UTC, Monkyyy wrote: On Thursday, 21 August 2025 at 05:38:08 UTC, evilrat wrote: On Wednesday, 20 August 2025 at 15:33:45 UTC, monkyyy wrote: once again dconf contains people who talk about compile speed as if it can be slow What are they doing? Even my

Re: How to make a slow compile

2025-08-21 Thread evilrat via Digitalmars-d-learn
On Thursday, 21 August 2025 at 13:52:32 UTC, Monkyyy wrote: On Thursday, 21 August 2025 at 05:38:08 UTC, evilrat wrote: On Wednesday, 20 August 2025 at 15:33:45 UTC, monkyyy wrote: once again dconf contains people who talk about compile speed as if it can be slow What are they doing? Even my

Re: How to make a slow compile

2025-08-20 Thread evilrat via Digitalmars-d-learn
On Wednesday, 20 August 2025 at 15:33:45 UTC, monkyyy wrote: once again dconf contains people who talk about compile speed as if it can be slow What are they doing? Even my worse compile time abstraction was O(n^2) or maybe some awful string concatenation of an entire file; still effectively

Re: Shadowing member in inheritance hierarchy - why

2025-08-08 Thread evilrat via Digitalmars-d-learn
On Saturday, 9 August 2025 at 04:02:03 UTC, Brother Bill wrote: On Saturday, 9 August 2025 at 01:33:03 UTC, user1234 wrote: On Friday, 8 August 2025 at 23:52:31 UTC, Brother Bill wrote: D language supports shadowing members, where the shadowed member has same name and different type on same typ

Re: std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-25 Thread evilrat via Digitalmars-d-learn
On Friday, 25 July 2025 at 01:04:31 UTC, Brother Bill wrote: From "Programming in D" book: import std.stdio; import std.random; void main() { int number = uniform(1, 101); writeln("Edit source/app.d to start your project."); } Running it generates: phobos64.lib

Re: Best way to get a dub generate visuald-generated visuald project to be a .lib / .obj for static linking?

2025-06-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 18 June 2025 at 02:20:11 UTC, Daniel Donnelly, Jr. wrote: I messed with the settings in the VisualD project settings from within visual studio: Compiler: DMD Output Type: Library Subsystem: Windows Output Path: (absolute path to my project root folder) Intermediate Path: (ditto)\o

Re: Windows thread pool

2025-05-20 Thread evilrat via Digitalmars-d-learn
On Monday, 19 May 2025 at 16:01:12 UTC, Python wrote: If I am using the integrated Windows Thread Pool (1), how this will interact with garbage collection? It won't even know this threads exists, this also means that your next question: Is there any risk that some objects are never freed or

Re: extern(C++): override nonvirtual member function

2025-04-25 Thread evilrat via Digitalmars-d-learn
On Friday, 25 April 2025 at 16:59:10 UTC, sfp wrote: On Friday, 25 April 2025 at 05:24:55 UTC, evilrat wrote: both f() would be marked `final` in D which will tell it is 'nonvirtual override', and then you will have more headache. I don't care if I have a headache or not, I n

Re: extern(C++): override nonvirtual member function

2025-04-24 Thread evilrat via Digitalmars-d-learn
On Thursday, 24 April 2025 at 19:41:48 UTC, sfp wrote: I'm trying to wrap some C++ classes, and one issue I've run into is having an extern(C++) class inheriting from another, with the child doing a "nonvirtual override" of a nonvirtual member function in the base class... E.g., in C++: ``` st

Re: Obtaining an address given a (run time) variable name

2025-01-21 Thread evilrat via Digitalmars-d-learn
On Tuesday, 21 January 2025 at 09:34:29 UTC, DLearner wrote: On Tuesday, 21 January 2025 at 05:54:48 UTC, evilrat wrote: On Monday, 20 January 2025 at 22:32:02 UTC, DLearner wrote: It was because my understanding was that in certain situations the string construct did not just produce a

Re: Obtaining an address given a (run time) variable name

2025-01-20 Thread evilrat via Digitalmars-d-learn
On Monday, 20 January 2025 at 22:32:02 UTC, DLearner wrote: It was because my understanding was that in certain situations the string construct did not just produce a character array - it also produced the (to me horrible) concept of adding a x'00' immediately after the last character of the ar

Re: Secure dependency management

2025-01-05 Thread evilrat via Digitalmars-d-learn
On Monday, 6 January 2025 at 03:04:40 UTC, Chris Piker wrote: Here's what I ended up doing in case it's either useful for others, or a really bad idea and serves as an anti-example. 0) For context, the working directory has roughly this setup (after git submodule calls): ``` git-root |-- mai

Re: Secure dependency management

2025-01-04 Thread evilrat via Digitalmars-d-learn
On Saturday, 4 January 2025 at 20:33:55 UTC, Chris Piker wrote: Hi D So one of the projects I've been working on is moving closer to production. Currently, the pull/build/test/install cycle is handled by git, dub and GNU make. Currently I let dub fetch dependencies off the Internet, but for

Re: Open a folder with explorer.exe

2024-12-28 Thread evilrat via Digitalmars-d-learn
On Saturday, 28 December 2024 at 19:25:48 UTC, bauss wrote: On Saturday, 28 December 2024 at 19:23:39 UTC, Jordan Wilson wrote: On Saturday, 28 December 2024 at 18:55:08 UTC, bauss wrote: I cannot figure out how to get spawnProcess working with explorer.exe on Windows. Been trying to call it

Re: Function names, Lib used from C and D

2024-10-22 Thread evilrat via Digitalmars-d-learn
On Tuesday, 22 October 2024 at 12:44:22 UTC, Maximilian Naderer wrote: Dear community, I want to create a library which is usable from C and D. D should be a first class citizen and C because of FFI for other languages. The lib is compiled with -betterC Because C does not have namespaces i wan

Re: List classes at compile time

2024-10-19 Thread evilrat via Digitalmars-d-learn
On Saturday, 19 October 2024 at 08:51:20 UTC, Noé Falzon wrote: tl;dr: is it possible to iterate over all classes in a program at compile time (or possibly all derived classes from a given base class) to use in a mixin? No, parent class can not possibly know who extends it, just think about

Re: Splitting a project into different executable files

2024-10-11 Thread evilrat via Digitalmars-d-learn
On Saturday, 12 October 2024 at 01:09:56 UTC, Alexander Zhirov wrote: Is it possible to organize a project that will consist of several main files. I want to write several simple programs in one project, but for them to be divided into different files. So that it would be possible to choose dur

Re: Wrapper for PAM

2024-10-07 Thread evilrat via Digitalmars-d-learn
On Monday, 7 October 2024 at 08:23:08 UTC, Alexander Zhirov wrote: I tried to build a class with a private function `conversation_func` to call it inside the public authentication function. When compiling I get this message: ``` source/login/auth.d(87,46): Deprecation: casting from extern (C)

Re: Associative Array, get value instead of poiter using `if (auto ..)`, possible?

2024-09-01 Thread evilrat via Digitalmars-d-learn
On Sunday, 1 September 2024 at 08:50:53 UTC, ryuukk_ wrote: if checking for/getting a value from a hashmap requires all that crap, then perhaps something is wrong with the language, and it perhaps isn't the one i should have picked for the task my mistake perhaps, not yours besides, i do u

Re: How do you typically debug / write D code (Visual Studio - known to be broken in Error pane etc), VScode - I get this error...

2024-08-19 Thread evilrat via Digitalmars-d-learn
On Monday, 19 August 2024 at 10:59:33 UTC, Daniel Donnelly, Jr. wrote: I give up on Visual Studio VisualD plugin as it's had the same issues for over five years, and currently my program runs from the command line, but VisualD complains with a 528 nonsensical errors. So I investigated using V

Re: Being reading a lot about betterC, but still have some questions

2024-07-09 Thread evilrat via Digitalmars-d-learn
On Tuesday, 9 July 2024 at 07:54:12 UTC, kiboshimo wrote: Hi, Some stuff must look obvious to an experienced programmer so they are not explicit on articles and documentation over the internet. I'm somewhat inexperienced, so: - betterC does not need glue code to interop with C. Does it achi

Re: Pointer to dlang spec for this alias construct?

2024-06-16 Thread evilrat via Digitalmars-d-learn
On Monday, 17 June 2024 at 04:32:50 UTC, Andy Valencia wrote: In the alias: alias Unshared(T) = T; alias Unshared(T: shared U, U) = U; as used in: cast(Unshared!mytype)value turns a mytype with shared attribute into one without shared. I deduce the alias is using some sort of typ

Re: How to use D without the GC ?

2024-06-12 Thread evilrat via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 17:00:14 UTC, Vinod K Chandran wrote: On Wednesday, 12 June 2024 at 10:16:26 UTC, Sergey wrote: Btw are you going to use PyD or doing everything manually from scratch? Does PyD active now ? I didn't tested it. My approach is using "ctypes" library with my dll.

Re: Unintentional sharing?

2024-06-06 Thread evilrat via Digitalmars-d-learn
On Thursday, 6 June 2024 at 17:49:39 UTC, Andy Valencia wrote: I was using instance initialization which allocated a new object. My intention was this initialization would happen per-instance, but all instances appear to share the same sub-object? That is, f1.b and f2.b appear to point to a s

Re: How to pass in reference a fixed array in parameter

2024-06-05 Thread evilrat via Digitalmars-d-learn
On Wednesday, 5 June 2024 at 11:27:32 UTC, Nick Treleaven wrote: On Wednesday, 5 June 2024 at 09:24:23 UTC, evilrat wrote: for simple cases like this it might work, but 2d array is not even contiguous, A 2D static array is contiguous: https://dlang.org/spec/arrays.html#rectangular-arrays D

Re: How to pass in reference a fixed array in parameter

2024-06-05 Thread evilrat via Digitalmars-d-learn
On Wednesday, 5 June 2024 at 06:22:34 UTC, Eric P626 wrote: On Tuesday, 4 June 2024 at 16:19:39 UTC, Andy Valencia wrote: On Tuesday, 4 June 2024 at 12:22:23 UTC, Eric P626 wrote: Thanks for the comments. So far, I only managed to make it work by creating a dynamic array and keeping the same

Re: How to pass in reference a fixed array in parameter

2024-06-04 Thread evilrat via Digitalmars-d-learn
On Tuesday, 4 June 2024 at 12:22:23 UTC, Eric P626 wrote: I am currently trying to learn how to program in D. I thought that I could start by trying some maze generation algorithms. I have a maze stored as 2D array of structure defined as follow which keep tracks of wall positions: ~~~ struct

Re: need help to use C++ callback from garnet

2024-05-29 Thread evilrat via Digitalmars-d-learn
On Wednesday, 29 May 2024 at 07:47:01 UTC, Dakota wrote: I try use https://github.com/microsoft/garnet/blob/main/libs/storage/Tsavorite/cc/src/device/native_device_wrapper.cc from D Not sure how to make this work with D: ```c++ EXPORTED_SYMBOL FASTER::core::Status NativeDevice_ReadAsync(Nat

Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread evilrat via Digitalmars-d-learn
On Friday, 10 May 2024 at 13:27:40 UTC, Dukc wrote: Steven Schveighoffer kirjoitti 10.5.2024 klo 16.01: On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote: This also gets inferred as `pure` - meaning that if you use it twice for the same `WeakRef`, the compiler may reuse the result of the firs

Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-09 Thread evilrat via Digitalmars-d-learn
On Thursday, 9 May 2024 at 00:39:49 UTC, Liam McGillivray wrote: What's a good way I can achieve what I'm trying to do, using either reference counting or a garbage-collected object? There is libraries like `automem`[1] that implements refcounting and more. Without showing your code for ref

Re: Question on shared memory concurrency

2024-03-04 Thread evilrat via Digitalmars-d-learn
On Monday, 4 March 2024 at 16:02:50 UTC, Andy Valencia wrote: On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew Cattermole wrote: A way to do this without spawning threads manually: ... Thank you! Of course, a thread dispatch per atomic increment is going to be s.l.o.w., so not

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-19 Thread evilrat via Digitalmars-d-learn
On Friday, 19 January 2024 at 16:55:25 UTC, ryuukk_ wrote: You do hash map lookup for every character in D, it's slow, whereas in Rust you do it via pattern matching, java does the same, pattern matching Yet another reason to advocate for pattern matching in D and switch as expression Th

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 11:20:14 UTC, Renato wrote: That means the input file is still not ASCII (or UTF-8) as it should. Java is reading files with the ASCII encoding so it should've worked fine. It seems that it is only works with ASCII encoding though.

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 10:43:22 UTC, Renato wrote: On Wednesday, 17 January 2024 at 10:24:31 UTC, Renato wrote: It's not Java writing the file, it's the bash script [`benchmark.sh`](https://github.com/renatoathaydes/prechelt-phone-number-encoding/blob/master/benchmark.sh#L31): ```

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 07:06:25 UTC, Renato wrote: On Tuesday, 16 January 2024 at 22:15:04 UTC, Siarhei Siamashka wrote: On Tuesday, 16 January 2024 at 21:15:19 UTC, Renato wrote: It's a GC allocations fest. Things like this make it slow: ```diff { -string digit = [digit

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-17 Thread evilrat via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 07:11:02 UTC, Renato wrote: If you want to check your performance, you know you can run the `./benchmark.sh` yourself? Out of curiosity I've tried to manually run this on Windows and it seems that Java generator for these numbers files is "broken", the resul

Re: Less verbose or at least "higher level" 2D game engines for Dlang.

2023-12-29 Thread evilrat via Digitalmars-d-learn
On Saturday, 30 December 2023 at 00:47:04 UTC, Agent P. wrote: Hello everyone, I'm looking for a 2D game engine for Dlang that offers flexibility but has a high-level interface, preferably less verbose. Although I've explored options on GitHub and in general, I haven't found something that ex

Re: [vibe] what's wrong with linking time of vibe applications?

2023-12-24 Thread evilrat via Digitalmars-d-learn
On Friday, 22 December 2023 at 19:12:14 UTC, Dmitry Ponyatov wrote: D lang noted as having a very fast compilation time. Playing with tiny web-interface apps I found that modern versions of dmd & vibe has such a fast compiling but a very long executable linking time. Something like 2-3 secon

Re: [vibe] statically precompile some JS libs into an app binary

2023-12-24 Thread evilrat via Digitalmars-d-learn
On Friday, 22 December 2023 at 19:55:07 UTC, Dmitry Ponyatov wrote: It is possible to statically precompile some JS libs and media fragments into an app binary? My colleagues asks me to distribute app as a single standalone executable if it is possible, and maybe few millisecond of page load

Re: What is :-) ?

2023-11-20 Thread evilrat via Digitalmars-d-learn
On Monday, 20 November 2023 at 16:09:33 UTC, Antonio wrote: Is there any way to force D compiler to treat this "createCounter" declaration as **delegate** instead of **function**? ```d auto createCounter = (int nextValue) => () => nextValue++; ``` generally there is a way to tell the com

Re: What is :-) ?

2023-11-20 Thread evilrat via Digitalmars-d-learn
On Monday, 20 November 2023 at 09:44:32 UTC, Antonio wrote: - Why writeln doesn't treat ```next``` and ```Counter``` the same way? (I think I understand why, but it shows a "low" level difference of something that syntactically is equivalent) - What is the way to show Counter signature usin

Re: What is :-) ?

2023-11-20 Thread evilrat via Digitalmars-d-learn
On Monday, 20 November 2023 at 08:47:34 UTC, Antonio wrote: Now, I uncomment the ```writeln( "'Counter' is ", Counter );``` line and compiler says ``` /home/antonio/Devel/topbrokers/whatsapp-srv/admin/x.d(12): Error: function `x.Counter(int nextValue)` is not callable using argument types `

Re: Translating C precompiler macros to D

2023-11-09 Thread evilrat via Digitalmars-d-learn
On Wednesday, 8 November 2023 at 20:43:21 UTC, solidstate1991 wrote: Here's this precompiler macro from Pipewire, on which many important inline functions depend on, like this one: ```c /** * Invoke method named \a method in the \a callbacks. * The \a method_type defines the type of the metho

Re: Symbolic computations in D

2023-10-29 Thread evilrat via Digitalmars-d-learn
On Sunday, 29 October 2023 at 10:44:03 UTC, ryuukk_ wrote: If D had tagged union and pattern matching, it would be a great candidate to succeed in that field Well, we sort of have it, just not as good as it can be. https://dlang.org/phobos/std_sumtype.html The default example though makes i

Re: Symbolic computations in D

2023-10-29 Thread evilrat via Digitalmars-d-learn
On Sunday, 29 October 2023 at 08:55:24 UTC, Dmitry Ponyatov wrote: Maybe someone played in this topic, and can give some advice: is D language with its OOP without multiple inheritance and maybe other semantic limitations able and good enough to be used with these books mechanics? You can hav

Re: Can't get into debugger in vscode on macOS

2023-10-19 Thread evilrat via Digitalmars-d-learn
On Thursday, 19 October 2023 at 06:03:06 UTC, Daniel Zuncke wrote: Hello, I need some help getting into the debugger in vscode on macOS. It did work some months ago but that was finicky to set up. Maybe I am forgetting something now? I am compiling the project with `dub build --build debug --

Re: How to get all modules in a package at CT?

2023-10-05 Thread evilrat via Digitalmars-d-learn
On Thursday, 5 October 2023 at 22:32:36 UTC, mw wrote: So ModuleInfo contains all the modules (transitive closure) built into the current binary that is running? Is there document about this ModuleInfo? I only find Struct object.ModuleInfo https://dlang.org/library/object/module_info.html

Re: Meaning of the dot-function syntax

2023-10-01 Thread evilrat via Digitalmars-d-learn
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote: Hi, What's the meaning of the dot in the call to writeln() below? ```d .writeln("Hello there!"); ``` I haven't found this in the spec or anywhere else. This is used very often in the source code for Phobos. Thanks, dhs It is either

Re: change object class

2023-09-17 Thread evilrat via Digitalmars-d-learn
On Sunday, 17 September 2023 at 15:05:59 UTC, Vitaliy Fadeev wrote: It works! But I want to ask how to make this 100% the best of the best? What should I consider before changing ```__vptr``` ? If that works for you with that constraint of having exact memory layout then it should be ok. Th

Re: pipeProcess output to hash string

2023-09-09 Thread evilrat via Digitalmars-d-learn
On Saturday, 9 September 2023 at 16:49:30 UTC, user1234 wrote: not sure why you append "/?" to the program name. Windows maybe? Try this. auto result = std.process.pipeProcess(["whoami", "/?"], redirect);

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread evilrat via Digitalmars-d-learn
On Friday, 8 September 2023 at 11:50:52 UTC, rempas wrote: That's interesting, I wasn't able to find something else! The bug happens when I run the testing suit and well... the tests before pass so I cannot find anything that goes wrong except for the fact that I do not free the memory that i

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread evilrat via Digitalmars-d-learn
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote: I do have the following struct: ```d struct Vec(T) { private: T* _ptr = null; // The pointer to the data u64 _cap = 0; // Total amount of elements (not bytes) we can store public: /* Create a vector by just allocating memory f

Re: I don't understand betterC

2023-09-04 Thread evilrat via Digitalmars-d-learn
On Monday, 4 September 2023 at 07:39:21 UTC, confused wrote: So then I guess I'd still like to know how I'm expected to store and access an array of characters without the C runtime as I tried in my original post. Without C runtime functions such as malloc you can still have fixed-length ar

Re: I don't understand betterC

2023-09-01 Thread evilrat via Digitalmars-d-learn
On Saturday, 2 September 2023 at 03:27:51 UTC, confused wrote: So I guess my next question is why, exactly, classes *can*, in fact, be implemented in ``` betterC ```, but are not? IIRC you can have extern(C++) classes in betterC, the real issue is the plain extern(D) classes which has some ass

Re: I don't understand betterC

2023-09-01 Thread evilrat via Digitalmars-d-learn
On Friday, 1 September 2023 at 13:17:08 UTC, confused wrote: On Friday, 1 September 2023 at 08:19:55 UTC, Richard (Rikki) Andrew Cattermole wrote: ``size_t`` is defined in ``object.d`` which is implicitly imported into all modules. If it cannot be found, one of three things is happening: 1) Y

Re: Using Windbg to debug D applications and unittests

2023-02-25 Thread evilrat via Digitalmars-d-learn
On Saturday, 25 February 2023 at 19:31:10 UTC, solidstate1991 wrote: Well, VS turned to be even less cooperative than before. Now it only loads and runs a specific old version of an EXE file. I'm asking around for other debuggers, I'm definitely moving to another. Nothing happens without a

Re: Using Windbg to debug D applications and unittests

2023-02-25 Thread evilrat via Digitalmars-d-learn
On Saturday, 25 February 2023 at 16:58:44 UTC, solidstate1991 wrote: I used to use Visual Studio, but I forgot how to set it up properly to break on handled throws. Now it doesn't do anything if throws are handled in any fashion, and I can't find an option to change it (it was removed maybe?)

Re: Using Windbg to debug D applications and unittests

2023-02-25 Thread evilrat via Digitalmars-d-learn
On Saturday, 25 February 2023 at 15:55:33 UTC, solidstate1991 wrote: I had a lot of trouble trying to get Visual Studio to catch handled exceptions VisualD for Visual Studio provides some extra help with displaying your data in debugger and on Windows is the best you can get for D. You can

Re: How to a link to a C library to create static bindings?

2023-01-27 Thread evilrat via Digitalmars-d-learn
On Saturday, 28 January 2023 at 02:40:58 UTC, thebluepandabear wrote: I am really confused as to how I even am supposed to get the library name in the first place, which is another thing that is confusing me. It is up to the library author to choose a name. The extensions is `.so/.dll/.dy

Re: Hipreme's #8 Tip of the day - Using custom runtime with dub projects

2023-01-22 Thread evilrat via Digitalmars-d-learn
On Sunday, 22 January 2023 at 18:16:35 UTC, Hipreme wrote: Nope. Those DFLAGS environment variable is used to affect projects such as my dependencies. For example, my dependency needs to be built using my own runtime. The dflags defined in the dub.json only affect the current project, not its

Re: Hipreme's #8 Tip of the day - Using custom runtime with dub projects

2023-01-22 Thread evilrat via Digitalmars-d-learn
On Sunday, 22 January 2023 at 16:57:56 UTC, Hipreme wrote: The way to use dub's packages is by using the DFLAGS. With DFLAGS, I can set the import path to my own DRuntime and own std. That way I can make the dependencies behave more or less the same, this is an example of what is being done n

Re: Function which returns a sorted array without duplicates

2023-01-21 Thread evilrat via Digitalmars-d-learn
On Sunday, 22 January 2023 at 04:42:09 UTC, dan wrote: I would like to write a function which takes an array as input, and returns a sorted array without duplicates. ```d private S[] _sort_array( S )( S[] x ) { import std.algorithm; auto y = x.dup; y.sort; auto z =

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

2023-01-20 Thread evilrat via Digitalmars-d-learn
On Friday, 20 January 2023 at 13:17:05 UTC, Ruby The Roobster wrote: On Friday, 20 January 2023 at 13:03:18 UTC, thebluepandabear wrote: ll a function without instantiating said class, as functions act on the class object. Ok, thanks. I think D should implement something similar to `static c

Re: Vibe.d serve files from filesystem

2023-01-12 Thread evilrat via Digitalmars-d-learn
On Wednesday, 11 January 2023 at 18:56:47 UTC, eXodiquas wrote: Hello everyone, I build a web tool that allows people to upload some files. Those files should not be public, so I copy them into a folder hidden away on the filesystem. But, I want an authenticated user to be able to look at the

Re: Background thread, async and GUI (dlangui)

2022-07-11 Thread evilrat via Digitalmars-d-learn
On Sunday, 10 July 2022 at 09:15:59 UTC, Bagomot wrote: Based on Thread, I managed to do what I intended. I have not yet been able to figure out how to do the same through the Task. Here in the example, when you click on the Start button, a worker is launched that updates the progress bar. .

Re: What happened to Circular Studio?

2022-06-08 Thread evilrat via Digitalmars-d-learn
On Monday, 6 June 2022 at 21:07:58 UTC, Steven Schveighoffer wrote: On 6/6/22 3:46 PM, Jack wrote: I just found out a game using D to develop games but later I see the last updates on the github, web site, twitter etc is from 2015. Does anyone knows what happend to the company? It appears to

Re: Trying to cross compile from windows to android

2022-01-21 Thread evilrat via Digitalmars-d-learn
On Thursday, 20 January 2022 at 19:31:06 UTC, H. S. Teoh wrote: I'm not sure how it works on Windows, but there should be corresponding binaries that might give a hint as to what's the correct -fuse-ld=... option you need to use. Here I documented some of the quirks I've hit during android

Re: Good intellisense support IDE/Editor?

2021-12-22 Thread evilrat via Digitalmars-d-learn
On Wednesday, 22 December 2021 at 10:37:51 UTC, Michel wrote: Hey, I've tried coding in Visual Studio Code but there isn't any function checking/showing what arguments a function accepts, I can just write `Foo.Bar("somerandomarg");` and it will not give me errors or warnings. Which IDE do you

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread evilrat via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 12:02:08 UTC, Jan wrote: On Wednesday, 15 December 2021 at 11:03:27 UTC, rikki cattermole wrote: On 15/12/2021 11:54 PM, Jan wrote: On Wednesday, 15 December 2021 at 09:36:54 UTC, Jan wrote: Unfortunately it's the "annoying little details" that I immediately

Re: How to pass a class by (const) reference to C++

2021-12-13 Thread evilrat via Digitalmars-d-learn
On Tuesday, 14 December 2021 at 06:21:39 UTC, Tejas wrote: Hey, evilrat, I've seen people make claims that our C++ interop has reached phenomenal levels and that going any further would basically require a C++ compiler ala ImportC++, the issue is just that the docs haven't been u

Re: How to pass a class by (const) reference to C++

2021-12-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 December 2021 at 12:16:03 UTC, Ola Fosheim Grøstad wrote: On Monday, 13 December 2021 at 12:08:30 UTC, evilrat wrote: Yeah but it sucks to have making C++ wrapper just for this. I think either pragma mangle to hammer it in place or helper dummy struct with class layout that

Re: How to pass a class by (const) reference to C++

2021-12-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 December 2021 at 11:13:12 UTC, Tejas wrote: On Monday, 13 December 2021 at 09:21:26 UTC, Jan wrote: On Monday, 13 December 2021 at 07:48:34 UTC, evilrat wrote: On Sunday, 12 December 2021 at 21:24:39 UTC, Jan wrote: In D I have an extern(C++) class: ```cpp extern(C++) class A

Re: How to pass a class by (const) reference to C++

2021-12-12 Thread evilrat via Digitalmars-d-learn
On Sunday, 12 December 2021 at 21:24:39 UTC, Jan wrote: In D I have an extern(C++) class: ```cpp extern(C++) class A { ~this(); // other stuff } ``` An a function that takes A by const reference: ```cpp void CppFunc(const A& arg); ``` But how do I bind this in D ? ```cpp extern(C++)

Re: How to "stringnify"?

2021-10-10 Thread evilrat via Digitalmars-d-learn
On Sunday, 10 October 2021 at 08:28:30 UTC, rempas wrote: Is there a way to "stringnify" in Dlang? In C we would do something like the following: `#define STRINGIFY(x) #x` What's the equivalent in D? That's probably depends on what you are trying to achieve. If you want to write code-like s

Re: What is the meaning of @future ?

2021-09-18 Thread evilrat via Digitalmars-d-learn
On Saturday, 18 September 2021 at 08:02:13 UTC, Dylan Graham wrote: On Friday, 17 September 2021 at 14:37:29 UTC, Meta wrote: On Friday, 17 September 2021 at 10:31:34 UTC, bauss wrote: On Thursday, 16 September 2021 at 20:53:34 UTC, Elmar wrote: [...] It's just another "useless" attribute th

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-21 Thread evilrat via Digitalmars-d-learn
On Saturday, 21 August 2021 at 23:50:51 UTC, Ruby The Roobster wrote: On Saturday, 21 August 2021 at 23:50:08 UTC, Ruby The Roobster wrote: On Saturday, 21 August 2021 at 06:08:17 UTC, evilrat wrote: First parameter for CreateWindow should be window class string that you used in

Re: C to D convertor

2021-08-21 Thread evilrat via Digitalmars-d-learn
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев wrote: I know, i know... It not possible, but part of the C code we can to convert to the D. Show me, please, solutions, projects, tools, scripts, docs. Can you give the link ? `htod` is 1. Any more ? dstep https://code.dlang.org/pac

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-20 Thread evilrat via Digitalmars-d-learn
On Friday, 20 August 2021 at 21:19:09 UTC, Ruby The Roobster wrote: int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { // ... if(!RegisterClassA(&wndclass)) { return 0; } hwnd = CreateWindowA( "Test",

Re: D equivalent of C++ explicit

2021-08-19 Thread evilrat via Digitalmars-d-learn
On Thursday, 19 August 2021 at 18:04:58 UTC, Tejas wrote: On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote: On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote: As the topic says: Is there an equivalent to C++'s `explicit` keyword in D? No, because all constructors are exp

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread evilrat via Digitalmars-d-learn
On Thursday, 19 August 2021 at 15:12:03 UTC, Ferhat Kurtulmuş wrote: On Thursday, 19 August 2021 at 07:30:38 UTC, Bienlein wrote: Hello, I allocate some instance of class C manually and then free the memory again: [...] I just wanted to leave this here. https://github.com/AuburnSounds/Dplu

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread evilrat via Digitalmars-d-learn
On Thursday, 19 August 2021 at 08:25:23 UTC, Bienlein wrote: Oops, I just realized that you can also not call emplace when @nogc is present. Well that is at least consistent with not either being able to call destroy ;-). So, I guess this means that you can forget about manually allocating

Re: Two major problems with dub

2021-08-04 Thread evilrat via Digitalmars-d-learn
On Wednesday, 4 August 2021 at 07:21:56 UTC, Denis Feklushkin wrote: On Sunday, 1 August 2021 at 17:37:01 UTC, evilrat wrote: vibe-d - probably because it handles DB connection and/or keep things async way, sure you probably can do it with Phobos but it will be much more PITA and less

Re: Two major problems with dub

2021-08-01 Thread evilrat via Digitalmars-d-learn
On Sunday, 1 August 2021 at 17:25:26 UTC, Alain De Vos wrote: A simple example, dub package dpq2 pulls in, money,vide-d,stdx-allocator,derelict-pq,derelict-util This all for a handfull of C-functions. let's see Money - fits pretty ok, cause your average SQL has decimal type for that purpose b

Re: Two major problems with dub

2021-08-01 Thread evilrat via Digitalmars-d-learn
On Sunday, 1 August 2021 at 15:38:32 UTC, Alain De Vos wrote: 2. Let's say you need bindings to postgresql library and you will see dub pulling in numerous of libraries, which have nothing at all to do with postgresql. More like a framework stuff. This creates unneeded complexity, bloatware, de

Re: How to create friends of a class at compile time?

2021-07-15 Thread evilrat via Digitalmars-d-learn
On Thursday, 15 July 2021 at 17:49:06 UTC, Tejas wrote: I'm sorry, I should've explicitly mentioned I'm interested in learning how to do friend injection in D. I know that access specifiers operate at module scope, seen a few posts about that here already. Thank you for answering though.

Re: Why can't we transpile C++ to D?

2021-06-10 Thread evilrat via Digitalmars-d-learn
On Thursday, 10 June 2021 at 19:06:42 UTC, Tejas wrote: But how scalable will this be? We have to get real D code to enrich our ambiguously-defined-small ecosystem. It says bindings generator, but it has to convert the code keeping the semantic as close as possible. It does direct translat

Re: Why can't we transpile C++ to D?

2021-06-10 Thread evilrat via Digitalmars-d-learn
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote: Sorry, I'm rather ignorant when it comes to this, but why can't we use [pegged](https://github.com/PhilippeSigaud/Pegged) to transpile C++ code to D? Then we won't need a nogc compatible std library and so many other things could get easie

Re: Why can't we transpile C++ to D?

2021-06-10 Thread evilrat via Digitalmars-d-learn
On Thursday, 10 June 2021 at 15:57:44 UTC, Imperatorn wrote: On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote: Sorry, I'm rather ignorant when it comes to this, but why can't we use [pegged](https://github.com/PhilippeSigaud/Pegged) to transpile C++ code to D? Then we won't need a nogc c

Re: Class member initialization with new points to a single instance?

2021-06-09 Thread evilrat via Digitalmars-d-learn
On Wednesday, 9 June 2021 at 17:56:24 UTC, Gregor Mückl wrote: Consider the following code: ```d class Foo { } class Bar { Foo foo = new Foo(); } void main() { Bar b1 = new Bar(); Bar b2 = new Bar(); assert(b1.foo != b2.foo); } ``` The assert fails. This is completel

Re: Any 3D Game or Engine with examples/demos which just work (compile&run) out of the box on linux ?

2021-06-07 Thread evilrat via Digitalmars-d-learn
On Monday, 7 June 2021 at 14:02:14 UTC, Prokop Hapala wrote: Basically I'm desperate do find anything which encapsulates OpenGL calls into some nice D-lang classes to learn from it. I don't really want to use Dagon, nor Godot. What I want is to use it as learning resources fro learning graphi

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-02 Thread evilrat via Digitalmars-d-learn
On Wednesday, 2 June 2021 at 05:43:49 UTC, evilrat wrote: Yep, use Skia/Cairo or something like this, don't build your own full blown 2D engine for every possible graphics API. I would like to tune my C++ bindings generator to be able to handle Skia ASAP, but can't tell when

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread evilrat via Digitalmars-d-learn
Btw there is also (dear) imgui, which is immediate mode GUI that builds geometry to draw for you, how one would draw it is up to programmer. It is very popular in game dev because there is very little setup to get it working. Source https://github.com/ocornut/imgui D bindings with GL3 demo ht

Re: Any 3D Game or Engine with examples/demos which just work (compile&run) out of the box on linux ?

2021-06-01 Thread evilrat via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 20:07:39 UTC, Prokop Hapala wrote: After some sime I tried to return to this, using dependency on older version of dagon I got errors in dlib Not sure how to understadn this ``` Error: incompatible types for (box.pmax) - (box.center): both operands are of type Vecto

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread evilrat via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 06:31:28 UTC, Ola Fosheim Grostad wrote: On Tuesday, 1 June 2021 at 05:27:41 UTC, Imperatorn wrote: On Tuesday, 1 June 2021 at 03:32:50 UTC, someone wrote: [...] Yeah, "fragmentation" is a problem. We do a lot of things 90%. We need more "100% projects" that are ju

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-30 Thread evilrat via Digitalmars-d-learn
On Sunday, 30 May 2021 at 07:03:38 UTC, Chris Piker wrote: On Thursday, 27 May 2021 at 07:00:32 UTC, Imperatorn wrote: I would like to recommend DlangUI [1], but we have tried now for months to get in contact with the owner of it (to take over development) and are getting no reponse. 1. https

Re: How does inheritance and vtables work wrt. C++ and interop with D? Fns w/ Multiple-inheritance args impossible to bind to?

2021-05-25 Thread evilrat via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 18:12:27 UTC, Gavin Ray wrote: On Tuesday, 25 May 2021 at 18:03:00 UTC, evilrat wrote: That last one with someInt is what I warned about. D ctor messed up class layout, in this simple case where class data isn't used it almost works, but will be practically unu

Re: How does inheritance and vtables work wrt. C++ and interop with D? Fns w/ Multiple-inheritance args impossible to bind to?

2021-05-25 Thread evilrat via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 17:52:14 UTC, Gavin Ray wrote: ```d void main() { Derived dlangDerived = new Derived(123); printf("[D] Derived.Base1::getSomething() = %d \n", dlangDerived.getSomething()); printf("[D] Derived.Base2::getOtherThing() = %d \n", dlangDerived.getOtherThing()); pr

Re: How does inheritance and vtables work wrt. C++ and interop with D? Fns w/ Multiple-inheritance args impossible to bind to?

2021-05-25 Thread evilrat via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 08:10:25 UTC, sighoya wrote: On Tuesday, 25 May 2021 at 02:47:19 UTC, Gavin Ray wrote: The below seems to work at least, which is encouraging: Awesome! At least, it becomes problematic with fields in base classes, it would be nice if we could map them to @property

Re: How does inheritance and vtables work wrt. C++ and interop with D? Fns w/ Multiple-inheritance args impossible to bind to?

2021-05-24 Thread evilrat via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 02:47:19 UTC, Gavin Ray wrote: Unfortunately, it does not work if I try to add `final int getSomething()` or the other one to the D interfaces, it throws a symbol error because the mangled names are slightly different: ```sh unresolved external symbol "public: int

  1   2   3   4   5   >