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: 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: 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: 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: 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-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 st

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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: [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: [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: 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: 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: 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 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 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-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: 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: How to check that import module will succeed?

2019-07-25 Thread evilrat via Digitalmars-d-learn
On Friday, 26 July 2019 at 03:42:58 UTC, Andrey Zherikov wrote: Is there a way to check whether some module, say "foo", is available for import before doing "import foo"? I did some really retarded utility like this in the past, worked for me, but I can't say it is that well tested and there m

Re: How to check that import module will succeed?

2019-07-26 Thread evilrat via Digitalmars-d-learn
On Friday, 26 July 2019 at 14:56:37 UTC, Andrey Zherikov wrote: Even without static if I get the same result: mixin template my_import(alias modName) { mixin("import " ~ modName ~ ";"); } mixin my_import!"mymod"; pragma(msg,fullyQualifiedName!(myfunc)); // Error: undefined identifier

Re: Is it possible to disallow import for certain functions?

2019-07-27 Thread evilrat via Digitalmars-d-learn
On Saturday, 27 July 2019 at 12:48:12 UTC, BoQsc wrote: I seem to be doing something wrong, the result is the same. otherFile.d(8): Error: only one main, WinMain, or DllMain allowed. Previously found main at mainFile.d(11) private version = otherMain; version(otherMain) { void main

Re: How the hell to split multiple delims?

2020-02-16 Thread evilrat via Digitalmars-d-learn
On Sunday, 16 February 2020 at 09:57:26 UTC, AlphaPurned wrote: 1>Test.d(31): error : template ... 1>Test.d(61): error : template ... 1>Test.d(66): error : cannot implicitly convert expression `l` of type `immutable(char)` to `string` 1>Test.d(31): error : template ... 1>Test.d(79): error : te

Re: AA code 50x slower

2020-02-16 Thread evilrat via Digitalmars-d-learn
On Sunday, 16 February 2020 at 12:57:43 UTC, AlphaPurned wrote: template AA(string[] S) { auto _do() { int[string] d; foreach(s; S) d[s] = 0; return d; } enum AA = _do; } My best guess is that enum arrays(except strings) and AA's are instantiated every time you access them. T

Re: AA code 50x slower

2020-02-16 Thread evilrat via Digitalmars-d-learn
On Monday, 17 February 2020 at 02:18:15 UTC, AlphaPurned wrote: But the input to the AA is static, it never changes. I thought D would essentially treat it as a constant and compute it once? (I'm only using the AA in one place but it is in another template that is used twice. I can't imagine

Re: dub libs from home directory on windows

2020-03-18 Thread evilrat via Digitalmars-d-learn
On Wednesday, 18 March 2020 at 19:53:58 UTC, jmh530 wrote: On Wednesday, 18 March 2020 at 15:10:52 UTC, Виталий Фадеев wrote: On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote: I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to

Re: A question about C++ interop

2020-03-28 Thread evilrat via Digitalmars-d-learn
On Saturday, 28 March 2020 at 19:14:38 UTC, YD wrote: Hi, now I have a further question: when the C++ class A actually has a method that looks like virtual void get_info(std::string &s) const = 0; in order to preserve the virtual function table layout (I found that if I omit this functi

Re: Link error undefined symbol: __imp__InterlockedIncrement@4 on windows

2020-04-10 Thread evilrat via Digitalmars-d-learn
On Thursday, 9 April 2020 at 14:07:10 UTC, Clayton Alves wrote: I'm trying to compile my first hello world dub project, but when I run "dub" it spits this error: lld-link: error: undefined symbol: __imp__InterlockedIncrement@4 Does anybody have any clues what is going on ? This is from WinAP

Re: Is it possible to store different subclasses in one array?

2020-04-12 Thread evilrat via Digitalmars-d-learn
On Monday, 13 April 2020 at 04:21:48 UTC, Leonardo wrote: foreach (ref gi; GameItems) { if (gi == Weapon) gi.Attack() } How would it be? Replying myself... weapon = cast(Weapon) gi; if (weapon !is null) weapon.Attack() can be simplified as: if (auto weapon = cast(Weap

Re: Can I use Dlang in Qt5 instead C++ for develop Android Apps?

2020-04-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 April 2020 at 21:01:50 UTC, Baby Beaker wrote: I want develop Android apps using Qt5. But C++ is very hard. I want to use Dlang becouse Dlang is very easy. In theory nothing stops you from doing that. In practice however you have to deal with C++ anyway, how API matches ABI, and

Re: Linker error under Ubuntu

2020-05-14 Thread evilrat via Digitalmars-d-learn
On Thursday, 14 May 2020 at 16:09:16 UTC, solidstate1991 wrote: When I try to compile my own project under Ubuntu with dub, I get the following linker error: /usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd' //lib/x86_64-linux-gnu/libz.so

Re: Linker error under Ubuntu

2020-05-15 Thread evilrat via Digitalmars-d-learn
On Friday, 15 May 2020 at 23:49:37 UTC, solidstate1991 wrote: Dub should do the linking by itself. How does it know what to link?

Re: `this` template params for struct not expressing constness.

2020-06-08 Thread evilrat via Digitalmars-d-learn
On Monday, 8 June 2020 at 07:35:12 UTC, adnan338 wrote: Hi, as far as I understand, the `this` template parameter includes constness qualifiers as seen in https://ddili.org/ders/d.en/templates_more.html To apply this I have this following struct: module bst; struct Tree(T) { T item;

Re: Interfacing with C++ std::shared_ptr and std::unique_ptr

2020-06-09 Thread evilrat via Digitalmars-d-learn
On Wednesday, 10 June 2020 at 06:43:24 UTC, Andre Pany wrote: Also, the C++ classes make use of templates. Is it still possible to call these classes from D? It should be, I did something similar and it worked. But it was quite some time ago so I don't remember exact situation and any deta

Re: Does std.net.curl: download have support for callbacks?

2020-06-11 Thread evilrat via Digitalmars-d-learn
On Thursday, 11 June 2020 at 06:05:09 UTC, adnan338 wrote: I would like to set a callback for the `download()` function but I do not seem to find a way to add a callback to the procedure. Let's say, for example I have a GtkD Widget called "pb" (short for progressBar). I want to download a f

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 July 2020 at 09:34:35 UTC, zoujiaqing wrote: I changed string to basic_string. /// source/main.d import std.stdio; import core.stdcpp.string; extern(C++) { class Canvas { @disable this(); static Canvas Create(); basic_string!ubyte Foo();

Re: How to compile Windows exe files from this source

2020-08-09 Thread evilrat via Digitalmars-d-learn
On Sunday, 9 August 2020 at 19:04:07 UTC, Marc wrote: I don't know much more about D than creating a 'hello world' exe file with the DMD Compiler but I'm interested in using the eBay/tsv-utils binaries. Unfortunately, the author didn't create any MS Windows binaries: https://github.com/eBay/tsv-

Re: Getting Qte5 to work

2020-10-27 Thread evilrat via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 11:46:02 UTC, Josh Dredge wrote: Hi all, I'm completely new to D and while I'm not new to programming in general, I mostly do web development, Welcome! If by web development you also have back-end programming then you should be like 50% know how desktop programmi

Re: Iterating chars by Word

2020-11-12 Thread evilrat via Digitalmars-d-learn
On Friday, 13 November 2020 at 05:14:08 UTC, Виталий Фадеев wrote: Is: wchar[] chars; // like a: "import core.sys.windows.windows;\nimport std.conv : to;\n" Goal: foreach ( word; chars.byWord ) { // ... } You can make your own range, however look at this function first (second exa

Re: Getting started with graphqld

2020-12-17 Thread evilrat via Digitalmars-d-learn
On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote: connect a basic vibe-d app to a graphql backend. umm, what? Did you mean write graphql backend using vibe.d?

Re: C++ or D?

2020-12-23 Thread evilrat via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 18:03:56 UTC, frame wrote: It's not the problem mentioned but I had to struggle with DLLs and D's Variant-type. The problem is that Variant uses TypeInfo which does not pass DLL boundaries correctly so that int != int in runtime even it's in fact a simple int

Re: Developing and running D GUI app on Android

2021-01-10 Thread evilrat via Digitalmars-d-learn
On Sunday, 10 January 2021 at 18:58:13 UTC, aberba wrote: I'm looking to explore running a D application on Android based on Adams previous foundation work. However, I'm not familiar with the Android + D integration so I need some help. Has any of you successfully done that? Could use a sample

Re: Developing and running D GUI app on Android

2021-01-11 Thread evilrat via Digitalmars-d-learn
On Monday, 11 January 2021 at 07:38:00 UTC, Elronnd wrote: On Monday, 11 January 2021 at 06:26:41 UTC, evilrat wrote: Android itself is just linux under the hood, however the launcher starts java process that fires up your activity class (main in native languages) from there you just call your

Re: How build DCD on Windows?

2021-01-11 Thread evilrat via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 00:35:41 UTC, Marcone wrote: Hi, Someone can Help me build exe dcd server and client on WIndows? Step by step? Becouse the informations disponible is very hard to undestand. Are you serious? It's on the first page of their repo under the Setup section https://cod

Re: Collections in D

2021-01-13 Thread evilrat via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 12:06:05 UTC, Roguish wrote: What about sets? There is no specific set container, they just implemented as generic algorithms over the ranges. There is a section for set operations (std.algorithm.setops module). https://dlang.org/phobos/std_algorithm.html

Re: How to debug D on Linux

2021-01-13 Thread evilrat via Digitalmars-d-learn
if you are looking for back trace someone recently posted a hint for linux where there is no back trace by default is to import core.sys.linux.backtrace or something that has back trace info and using it in exception handler for runtime to print the stack trace. https://dlang.org/phobos/core_r

Re: Why doesn't this work when the function is a static method?

2021-01-14 Thread evilrat via Digitalmars-d-learn
On Thursday, 14 January 2021 at 05:44:43 UTC, Jack wrote: On Wednesday, 13 January 2021 at 17:21:23 UTC, Paul Backus wrote: Member functions (including static ones) can't be called with UFCS. is this documented somewhere? Is this going to change? It will stay as is. It is somewhat vaguel

Re: How can I specify flags for the compiler when --build=release in dub?

2021-01-15 Thread evilrat via Digitalmars-d-learn
On Friday, 15 January 2021 at 17:02:32 UTC, Jack wrote: is this possible? if so, how? You can add extra options for for platform and compiler, and IIRC for build type too. For example like this for lflags, it might complain about the order so just follow the instructions. "lflags-debug" "

Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-19 Thread evilrat via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 11:10:25 UTC, Marcone wrote: On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn wrote: On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote: How can I create a Standalone Bundle Portable file application using Dlang? Could you describe what you mean wi

Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-24 Thread evilrat via Digitalmars-d-learn
On Sunday, 24 January 2021 at 11:44:04 UTC, Marcone wrote: Qt5 dlls Well, you are out of luck. It is doable, but... Normally you would likely want to use static libraries and link them into your executable, with Qt license however it becomes problematic in pretty much any case, you still ca

Re: Dll crash in simplest case

2021-01-25 Thread evilrat via Digitalmars-d-learn
On Monday, 25 January 2021 at 11:30:45 UTC, Vitalii wrote: On Monday, 25 January 2021 at 10:26:20 UTC, frame wrote: [...] Yes. I'm doing it whet add dll.d (https://wiki.dlang.org/Win32_DLLs_in_D) in compile line, it contents: --- import core.sys.windows.windows; import core.sys.windows.dll;

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread evilrat via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 object.Error@(0): Integer Divide by Zero 0x004023FE 0x0040CF9F 0x0040CF19 0x0040CDB4 0x00409033 0x00402638 0x75F86359 in Ba

Re: Class Allocators

2021-01-31 Thread evilrat via Digitalmars-d-learn
On Sunday, 31 January 2021 at 23:19:09 UTC, Kyle wrote: My best guess right now is that both class allocators and the placement new syntax are deprecated, but if that's the case I would expect a deprecation message when I try to use that new(address) Type syntax whether there's a class allocato

Re: Can change vtbl record at runtime ?

2021-02-03 Thread evilrat via Digitalmars-d-learn
On Wednesday, 3 February 2021 at 08:26:05 UTC, Max Haughton wrote: On Wednesday, 3 February 2021 at 05:30:37 UTC, Виталий Фадеев wrote: Possible to change the vtbl record at runtime ? Has functional for update vtbl records ? Do you mean "Can I set onSuccess" at runtime? The virtual tables are

Re: Is there other way to do that?

2021-02-15 Thread evilrat via Digitalmars-d-learn
On Monday, 15 February 2021 at 07:26:56 UTC, Jack wrote: I need to check if an instance is of a specific type derived from my base class but this class has template parameter and this type isn't available at time I'm checking it. Something like: Non-templated interface/base class is probabl

Re: is it posible to compile individual module separately?

2021-02-16 Thread evilrat via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 07:01:53 UTC, bokuno_D wrote: i run "dub build" on it. but OOM kill the compiler. - is there a way to reduce memory consumtion of the compiler? or maybe third party tool? alternative to dub? Assuming you are using DMD, there is -lowmem switch to enable garbage c

Re: DUB is not working correctly

2021-02-24 Thread evilrat via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 16:13:48 UTC, Maxim wrote: Hello, I have problems with working in dub environment. If I try to init my project with 'dub init', all needed files will be created successfully. However, when I run 'dub run', the manager gives me an error: 'Configuration 'applic

Re: DUB is not working correctly

2021-02-24 Thread evilrat via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 16:46:20 UTC, Maxim wrote: Sure, here are dub.json contents: { "authors": [ "Max" ], "copyright": "Copyright © 2021, Max", "description": "A minimal D application.", "license": "proprietary", "depen

Re: DUB is not working correctly

2021-02-24 Thread evilrat via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 17:45:56 UTC, Maxim wrote: Unfortunately, I tried bindbc-sfml package but the problem is still existing. I also started a new project and without any changes ran it but the result was the same. Anyway, thank you so much for your help! does it works for an e

Re: DUB is not working correctly

2021-02-26 Thread evilrat via Digitalmars-d-learn
On Friday, 26 February 2021 at 18:20:38 UTC, Maxim wrote: On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: "targetType": "executable", and it should just run using "dub run" Unfortunately, the problem remains :/ Looks like something specific to your machine. The last thing I

Re: How can I make this work?

2021-02-27 Thread evilrat via Digitalmars-d-learn
On Sunday, 28 February 2021 at 07:05:27 UTC, Jack wrote: I'm using a windows callback function where the user-defined value is passed thought a LPARAM argument type. I'd like to pass my D array then access it from that callback function. How is the casting from LPARAM to my type array done in t

Re: Shared library module system with dub

2021-03-01 Thread evilrat via Digitalmars-d-learn
On Tuesday, 2 March 2021 at 04:26:52 UTC, Pillager86 wrote: On Tuesday, 2 March 2021 at 04:13:31 UTC, Pillager86 wrote: On Tuesday, 2 March 2021 at 03:42:14 UTC, Pillager86 wrote: Update: the dub "dynamicLibrary" target option is busted on Windows and does not build anything at all. This should

Re: Can't I allocate at descontructor?

2021-03-04 Thread evilrat via Digitalmars-d-learn
On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why? GC prohibits allocation during collection, since this dtor is likely called b

Re: Workaround to "import" an exception from a DLL

2021-03-14 Thread evilrat via Digitalmars-d-learn
On Sunday, 14 March 2021 at 09:35:40 UTC, frame wrote: // this returns null in the program (but works in a debugger watch): MyExceptionObj imported = cast(MyExceptionObj)e; // this actually works: MyExceptionObj imported = cast(MyExceptionObj) cast(void*)e; Is there are way to copy the e

Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread evilrat via Digitalmars-d-learn
On Monday, 15 March 2021 at 02:43:01 UTC, Tim wrote: On Monday, 15 March 2021 at 02:03:09 UTC, Adam D. Ruppe wrote: On Monday, 15 March 2021 at 01:53:31 UTC, Tim wrote: I'm needing to use a c/c++ library in a D program and I'm struggling with creating a binding as it seems like an enormous amo

Re: WinUI 3

2021-03-15 Thread evilrat via Digitalmars-d-learn
On Monday, 15 March 2021 at 16:41:08 UTC, Imperatorn wrote: Could D be used with WinUI 3? https://docs.microsoft.com/en-us/windows/apps/winui/winui3/ Would the win32metadata help? 🤔 I've seen some slides about WinUI 3 future directions and roadmap but haven't tried it yet. Probably it will b

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread evilrat via Digitalmars-d-learn
On Monday, 29 March 2021 at 15:13:04 UTC, Gavin Ray wrote: Brief question, is it possible to write this so that the "alias fn" here appears as the final argument? auto my_func(alias fn)(string name, string description, auto otherthing) The above seems to work, since the type of "fn" can va

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread evilrat via Digitalmars-d-learn
On Monday, 29 March 2021 at 17:52:13 UTC, Gavin Ray wrote: Trying to read this function signature: void my_func(T, XS)(string a, string b, string c, lazy T function(XS)[] t...) Does this say "Generic void function 'my_func', which takes two generic/type params "T" and "XS", and is a func

Re: Creating a .di file for a custom C library

2021-03-30 Thread evilrat via Digitalmars-d-learn
On Tuesday, 30 March 2021 at 04:01:12 UTC, Brad wrote: I would like to use an updated version of the Termbox library (written in C) with D. I have the .h file. This is new territory for me (why try something easy - right?). I think I need to create a .di file that corresponds to the .h file.

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-04-08 Thread evilrat via Digitalmars-d-learn
On Thursday, 8 April 2021 at 21:36:02 UTC, Alain De Vos wrote: The most important task is "give me a list of to include .d files" "give me a list of the link libraries .a .so" sure, use -v flag, this will give you compiler flags and other info ``` dub build -v ``` this will give you extens

Re: How to allow +=, -=, etc operators and keep encapsulation?

2021-04-12 Thread evilrat via Digitalmars-d-learn
On Monday, 12 April 2021 at 18:16:14 UTC, Jack wrote: Give this class: ```d class A { int X() { return x; } int X(int v) { return x = v;} private int x; } ``` I'd like to allow use ```+=```, ```-=``` operators on ```X()``` and keep encapsulation. What's a somehow elega

  1   2   3   >