Socket server + thread: cpu usage

2014-04-29 Thread Tim via Digitalmars-d-learn
Hi guys, I've the following snipped: TcpSocket oSocket = new TcpSocket(AddressFamily.INET); oSocket.bind(new InternetAddress(127.0.0.1, 12345)); oSocket.blocking(false); oSocket.listen(0); while(true) { try { Socket oRequestSocket = oSocket.accept();

Re: Socket server + thread: cpu usage

2014-04-29 Thread Tim via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your thread on hold until a new connection comes in.

Re: Socket server + thread: cpu usage

2014-04-29 Thread Tim via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:35:08 UTC, Tim wrote: On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your

Re: Socket server + thread: cpu usage

2014-05-01 Thread Tim via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your thread on hold until a new connection comes in.

Re: Socket server + thread: cpu usage

2014-05-01 Thread Tim via Digitalmars-d-learn
On Thursday, 1 May 2014 at 08:08:37 UTC, Tim wrote: On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your

Modify char in string

2014-05-18 Thread Tim via Digitalmars-d-learn
Hi everyone, is there any chance to modify a char in a string like: void main() { string sMyText = Replace the last char_; sMyText[$ - 1] = '.'; } But when I execute the code above I'm always getting cannot modify immutable expression at sMyText[__dollar -1LU]. I though D supported

Re: Modify char in string

2014-05-19 Thread Tim via Digitalmars-d-learn
On Sunday, 18 May 2014 at 19:09:52 UTC, Chris Cain wrote: On Sunday, 18 May 2014 at 18:55:59 UTC, Tim wrote: Hi everyone, is there any chance to modify a char in a string like: As you've seen, you cannot modify immutables (string is an immutable(char)[]). If you actually do want the string

How to handle try-catch blocks, nothrow and logfiles

2014-05-24 Thread Tim via Digitalmars-d-learn
I'm working on an application where I want log all exceptions but I'm not sure what's the best way to realize that. Sure I can do the following: void myMethod() nothrow { try { // Do something } catch (Exception e) { // Write log file } } But there are some

Re: How to handle try-catch blocks, nothrow and logfiles

2014-05-24 Thread Tim via Digitalmars-d-learn
On Saturday, 24 May 2014 at 17:55:07 UTC, Ali Çehreli wrote: On 05/24/2014 10:09 AM, Tim wrote: I'm working on an application where I want log all exceptions but I'm not sure what's the best way to realize that. A common solution is to log it in the exception class'es constructor. We even

crt1.o: could not read symbols: Bad value

2014-06-10 Thread Tim via Digitalmars-d-learn
Hi guys, I've the following few lines: module test; export: extern(D): int test() { return 0; } ... and compile it using the following line: dmd -m64 -fPIC -L-shared test.d -oflibtest.so But when I try to compile it, I always get the following error: /usr/bin/ld:

Re: crt1.o: could not read symbols: Bad value

2014-06-10 Thread Tim via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 20:29:56 UTC, FreeSlave wrote: dmd has -shared option. Try it instead of -L-shared. I'm getting a similar error: /usr/bin/ld: /usr/local/bin/../lib64/libphobos2.a(object__a_58c.o): relocation R_X86_64_32 against `_D10TypeInfo_m6__initZ' can not be used when

Re: Decimal type documentation

2014-06-11 Thread Tim via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 15:52:29 UTC, Poyeyo wrote: Hello, has anyone used this https://github.com/andersonpd/decimal implementation? I'm learning D and want to know where to start for the decimal (or bigfloat) stuff. The goal is to be able to read and write some data from a SQL DB

Re: crt1.o: could not read symbols: Bad value

2014-06-11 Thread Tim via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 10:09:50 UTC, FreeSlave wrote: I conclude that because I have similar errors when trying to build 64-bit library on 32-bit system. /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(format_712_5b3.o): relocation R_X86_64_32 against `.rodata' can not be used

Re: crt1.o: could not read symbols: Bad value

2014-06-11 Thread Tim via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 17:11:51 UTC, Tim wrote: On Wednesday, 11 June 2014 at 10:09:50 UTC, FreeSlave wrote: I conclude that because I have similar errors when trying to build 64-bit library on 32-bit system. /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(format_712_5b3.o):

Re: crt1.o: could not read symbols: Bad value

2014-06-12 Thread Tim via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 17:21:54 UTC, Tim wrote: On Wednesday, 11 June 2014 at 17:11:51 UTC, Tim wrote: On Wednesday, 11 June 2014 at 10:09:50 UTC, FreeSlave wrote: I conclude that because I have similar errors when trying to build 64-bit library on 32-bit system. /usr/bin/ld:

Initialization sequence of runtime environment

2014-06-13 Thread Tim via Digitalmars-d-learn
I recently posted another thread (regarding crt1.o: could not read symbols: Bad value - I'm creating a new thread because it's another problem) and I figured out that the following error: stack_bottom = 7fc98804ae18 thread_stack 0x4 /usr/sbin/mysqld(my_print_stacktrace+0x35)[0x8cea15]

Storing a reference to the calling object

2020-05-23 Thread Tim via Digitalmars-d-learn
Hi all, I'm a little new to D and I'm wondering how I can store a reference to the calling object. I want to create a reference to an object's parent so that each time I go to update the sprite, it is able to grab its position from the parent. So if I have: class Sprite{ /// Postional

Re: Storing a reference to the calling object

2020-05-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 May 2020 at 09:48:57 UTC, Mike Parker wrote: Since you're using classes, one way is to use a common base class or an interface. But assuming "parent" is the owner of the Sprite instance, you might eliminate the dependency on the parent and have it update the Sprite's position

Asserting that a base constructor is always called

2020-05-23 Thread Tim via Digitalmars-d-learn
I have a base class GameObject: /// Base class of most objects in the game class GameObject{ this(){ world[layer] = this; } abstract void update(){} void draw(){} } I want to make sure that whenever a class inherits from this, the base constructor is always called.

Re: Asserting that a base constructor is always called

2020-05-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 May 2020 at 22:15:49 UTC, Ali Çehreli wrote: Is it not already called? I tried the following and it seems to work: import std.stdio; GameObject[1] world; enum layer = 0; /// Base class of most objects in the game class GameObject{ this(){ world[layer] = this;

Re: Asserting that a base constructor is always called

2020-05-24 Thread Tim via Digitalmars-d-learn
On Sunday, 24 May 2020 at 00:51:17 UTC, Jonathan M Davis wrote: On Saturday, May 23, 2020 4:43:04 PM MDT Tim via Digitalmars-d-learn wrote: It is but I want to make sure for other cases in the future where I create a new class that inherits from GameObject. This was I can avoid future bugs

Re: Dub platform probes

2020-05-27 Thread Tim via Digitalmars-d-learn
On Wednesday, 27 May 2020 at 21:17:54 UTC, Andre Pany wrote: I read through the source code. The probe file is created here https://github.com/dlang/dub/blob/master/source/dub/compilers/utils.d#L296 The function getTempFile determines a new random temp file name and stores the file path in a

Dub platform probes

2020-05-25 Thread Tim via Digitalmars-d-learn
Hi all I end up with a directory flooded with platform probes. How can I make sure that old ones are deleted automatically? Thanks

Re: Dub platform probes

2020-05-26 Thread Tim via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 09:17:52 UTC, Andre Pany wrote: Hi, What version of dub do you use? I am not 100 % sure but thought platform probes do not longer write files with recent dub version. Do you use DMD or LDC or GDC? Kind regards Andre Hi there I'm using Dub 1.19.0-1build2 with dmd

Re: Member variables in method are null when called as delegate from thread

2021-01-12 Thread Tim via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 01:49:11 UTC, tsbockman wrote: The compiler and the physical CPU are both allowed to change the order in which instructions are executed to something different from what your code specifies, as long as the visible, "official" results and effects of the chosen

Member variables in method are null when called as delegate from thread

2021-01-10 Thread Tim via Digitalmars-d-learn
Hi there, I have something like this: class Foo{ MongoClient db; this(){ db = connectMongoDB("127.0.0.1"); void delegate()[string] commands = ["start": ]; MessageService messenger = new MessageService(8081, commands); } void start(){ // Do

Re: Member variables in method are null when called as delegate from thread

2021-01-10 Thread Tim via Digitalmars-d-learn
Ok, so it seems that it isn't null now. But I stall can't call db.getCollection().findAndModify() from vibe.d successfully here. Works just fine in the constructor. When it's called form the MessengerService thread it never returns from the function call

Re: Member variables in method are null when called as delegate from thread

2021-01-11 Thread Tim via Digitalmars-d-learn
On Monday, 11 January 2021 at 08:21:21 UTC, Arafel wrote: It's also possible that you'll have to make Foo itself `shared`, or at least convert your constructor into a `shared this ()` to get a shared instance that you can pass to a different thread, but I'm not sure how function pointers /

Issue with socket recieve

2021-01-20 Thread Tim via Digitalmars-d-learn
Hi all, I'm having a really terrible bug that seemed to come from nowhere and is really hard to narrow down. I have a threaded message service that works via local TcpSocket. Every time I run it, either an error saying: Unable to open 'recv.c': Unable to read file

Re: Issue with socket recieve

2021-01-20 Thread Tim via Digitalmars-d-learn
On Thursday, 21 January 2021 at 03:21:41 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 21:31:54 UTC, Tim wrote: Unable to open 'recv.c': Unable to read file '/build/glibc-ZN95T4/glibc-2.31/sysdeps/unix/sysv/linux/recv.c' (Error: Unable to resolve non-existing file

Re: Issue with socket recieve

2021-01-20 Thread Tim via Digitalmars-d-learn
On Thursday, 21 January 2021 at 03:35:05 UTC, Adam D. Ruppe wrote: On Thursday, 21 January 2021 at 03:24:13 UTC, Tim wrote: No, I don't. It should be all garbage collected right? Yeah, but that's where the problem comes. Note that by destructor, I mean *any* function in your code called

Exit code -4

2021-01-20 Thread Tim via Digitalmars-d-learn
Hi all, From time to time my program crashes with exit code -4. I can't seem to find much on the code. Does anyone know what this means and how to debug the issue?

Re: Exit code -4

2021-01-20 Thread Tim via Digitalmars-d-learn
On Thursday, 21 January 2021 at 00:47:36 UTC, Adam D. Ruppe wrote: On Thursday, 21 January 2021 at 00:37:19 UTC, Tim wrote: Hi all, From time to time my program crashes with exit code -4. I can't seem to find much on the code. Does anyone know what this means and how to debug the issue?

Re: Exit code -4

2021-01-20 Thread Tim via Digitalmars-d-learn
On Thursday, 21 January 2021 at 01:07:22 UTC, Paul Backus wrote: On Thursday, 21 January 2021 at 00:49:26 UTC, Tim wrote: Oh, so it's just signal 4, not -4? The signal is 4. The exit status is -4. https://en.wikipedia.org/wiki/Signal_(IPC)#POSIX_signals

Re: Issue with socket recieve

2021-01-20 Thread Tim via Digitalmars-d-learn
On Thursday, 21 January 2021 at 03:21:41 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 21:31:54 UTC, Tim wrote: Unable to open 'recv.c': Unable to read file '/build/glibc-ZN95T4/glibc-2.31/sysdeps/unix/sysv/linux/recv.c' (Error: Unable to resolve non-existing file

Generating documentation help

2021-01-17 Thread Tim via Digitalmars-d-learn
Hi there, I have a couple of (probably) fairly simple questions. First, when I generate documentation files (-Dd docs) for my project, it also generates documentation for the library Mir. How can I fix the compiler pulling in those docs as well? It seems that D won't let me document class

How can I use UFCS for a loop

2021-01-25 Thread Tim via Digitalmars-d-learn
Hi all, How can I change the following to a more D-like approach by using UFCS? double[3] result; Json json = res.readJson; for(int i = 0; i < json.length; i++){ result[i] = json[i].to!double; } I'd prefer to do something like: result = res.readJson[].map!(to!double);

Re: How can I use UFCS for a loop

2021-01-25 Thread Tim via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 01:38:45 UTC, Q. Schroll wrote: On Tuesday, 26 January 2021 at 00:47:09 UTC, Tim wrote: Hi all, How can I change the following to a more D-like approach by using UFCS? double[3] result; Unless you have a good reason, use a slice and not a static array:

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:45:19 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:38:41 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Sunday, 17 January 2021 at 22:27:13 UTC, Adam D. Ruppe wrote: On Sunday, 17 January 2021 at 21:48:20 UTC, Paul Backus wrote: I recommend using adrdox instead: note you should be able to just dub run adrdox and it will spit out `generated_docs/files...` (assuming i haven't broken that

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 23:57:21 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2021 at 23:51:00 UTC, Tim wrote: I'm creating a u-services based app so my apps need to be documented properly as well. I can get around this by defining them as modules but then adrdox doesn't add them to

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U such that T == U[]". Thanks! Do I need to specify U in the template function?

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U

How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
Hi all, I need to be able to check in a template whether the type given is an array type so that I can do some different logic. How can I do this? I would have thought that if(is(T == [])) would work, but no. Thanks in advance

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:03:16 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2021 at 23:58:59 UTC, Tim wrote: The main issue is that those scripts aren't being added to index.html Do they have module definitions and doc comments in there somewhere? like here I have all kinds

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 01:25:28 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 01:00:32 UTC, Tim wrote: But if I deleted index.html then reran the doc gen, it worked just fine. Looks like index.html is not being updated oh yeah i forgot i did that cuz I so often

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:13:42 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 00:06:35 UTC, Tim wrote: Yeah, they have both. They also contain the main entrypoint What are the module names? If it is like `module foo.main;` it will be listed under `foo` as a submodule

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:53:54 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 00:16:51 UTC, Tim wrote: They are defined "module simulator" and "module analyzer". I also have "module math" etc. that are added to the index That's weird... There are a bunch of command

How to define delegate with needed parameters

2021-01-13 Thread Tim via Digitalmars-d-learn
I would like to be able to create a delegate but also supply the function parameters to be used for the function call. How can I go about doing this? Example: void foo(int i){ } void bar(string m){ } doSomething((q)); doSomething(("test");

Re: How to define delegate with needed parameters

2021-01-13 Thread Tim via Digitalmars-d-learn
On Thursday, 14 January 2021 at 00:29:23 UTC, Paul Backus wrote: Easiest way is to use a lambda: doSomething(() => foo(q)) This worked perfectly, thank you for your timely response~

Re: Shutdown signals

2021-05-10 Thread Tim via Digitalmars-d-learn
On Monday, 10 May 2021 at 23:31:11 UTC, Adam D. Ruppe wrote: On Monday, 10 May 2021 at 23:20:47 UTC, Tim wrote: Hi all, How can I get a D program to detect something a keyboard interrupt so I shut things down in a specific way? import core.sys.posix.signal; then you can use the same

Shutdown signals

2021-05-10 Thread Tim via Digitalmars-d-learn
Hi all, How can I get a D program to detect something a keyboard interrupt so I shut things down in a specific way?

Re: Shutdown signals

2021-05-11 Thread Tim via Digitalmars-d-learn
On Monday, 10 May 2021 at 23:55:18 UTC, Adam D. Ruppe wrote: On Monday, 10 May 2021 at 23:35:06 UTC, Tim wrote: [...] dpldocs.info/signal it comes up as the second result. The C function you call from there (on linux anyway) is sigaction. A little copy/paste out of my terminal.d: ```d

Issue with small floating point numbers

2021-05-12 Thread Tim via Digitalmars-d-learn
Hello all, I have this piece of code ```D /** Rotate a 2D array (Vector) by phi radians Params: vec = 2D Vector to rotate phi = Degree with which to rotate the Vector in radians Returns: Rotated 2D array (Vector) Example: */ pragma(inline, true) Point2 rotate2D(in Point2 vec, in

Re: Issue with small floating point numbers

2021-05-12 Thread Tim via Digitalmars-d-learn
On Thursday, 13 May 2021 at 03:46:28 UTC, Alain De Vos wrote: Not is is not wrong it is wright. Because you use not pi but an approximation of pi the result is not zero but an approximation of zero. Oh, of course. Jesus that sucks big time. Any idea on how to use assert with an approximate

Re: Shutdown signals

2021-05-11 Thread Tim via Digitalmars-d-learn
On Tuesday, 11 May 2021 at 06:59:10 UTC, Patrick Schluter wrote: On Tuesday, 11 May 2021 at 06:44:57 UTC, Tim wrote: On Monday, 10 May 2021 at 23:55:18 UTC, Adam D. Ruppe wrote: [...] I don't know why I didn't find that. I was searching for the full name, maybe too specific? Thanks anyways,

How can I stop D from dropping decimals in strings

2021-02-02 Thread Tim via Digitalmars-d-learn
Hi all, I have to serialize an array like [0.0, 0.0, 0.0] to a Json object. During this process, the serializer creates a string of the array, but it creates "[0, 0, 0]", dropping the decimal. How can I stop this?

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

2021-03-14 Thread Tim via Digitalmars-d-learn
On Monday, 15 March 2021 at 02:47:12 UTC, Adam D. Ruppe wrote: On Monday, 15 March 2021 at 02:43:01 UTC, Tim wrote: Seems pretty good. Does it work on c++ stuff too? I don't think so Bother. Well, I'm sure it will still be useful though. Thanks for the heads up

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

2021-03-14 Thread Tim via Digitalmars-d-learn
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 amount of regex modifications. Is there an existing program that can create most if not all of a binding for me? Thanks

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

2021-03-14 Thread Tim via Digitalmars-d-learn
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 amount of regex modifications. Is there an existing

Vibe.d diet template help

2021-02-06 Thread Tim via Digitalmars-d-learn
Hi all, I'm trying to render a diet template out to a WebSocket as a string to be inserted into a specific portion of the currently served page. Does anyone know how to go about this?

Understanding range.dropBackOne

2021-09-28 Thread Tim via Digitalmars-d-learn
I'm doing the following: ```D int[25] window = 0; // Later in a loop window = someInteger ~ window[].dropBackOne; ``` But I'm struggling to understand why the following doesn't work ```D window = someInteger ~ window.dropBackOne; ``` What does the `[]` do exactly? Is an array not a

Re: Understanding range.dropBackOne

2021-09-28 Thread Tim via Digitalmars-d-learn
On Tuesday, 28 September 2021 at 23:12:14 UTC, Adam Ruppe wrote: On Tuesday, 28 September 2021 at 22:56:17 UTC, Tim wrote: [...] Note that this array has a fixed size. [...] Here the window[] takes a variable-length slice of it. Turning it from int[25] into plain int[]. Then you can drop

Better debugging?

2021-10-03 Thread Tim via Digitalmars-d-learn
Hi all, I am currently using GDB within VScode with the -gc DMD2 compiler switch and my debugging is not amazing. Whenever I inspect a struct/object it just shows me the pointer rather than the object information and strings come up as a gross array of the characters. Does anybody happen to

Re: Better debugging?

2021-10-03 Thread Tim via Digitalmars-d-learn
On Sunday, 3 October 2021 at 22:26:15 UTC, Imperatorn wrote: On Sunday, 3 October 2021 at 22:21:45 UTC, Tim wrote: [...] You don't say which operating system you are using. I usually use Visual D which works great imo. If I use vscode I use the C++ debug extension (don't remember what it's

Re: Small structs: interfacing with C++ potentially broken

2021-12-20 Thread Tim via Digitalmars-d-learn
On Monday, 20 December 2021 at 10:24:00 UTC, Jan wrote: Is this a known issue, or is there a way to instruct DMD to use a specific calling convention for a given type? This looks like a bug. It seems to work without constructor in C++, but still crashes with a constructor in D. It also seems

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: So what I am looking for then is the equivalent to __FUNCTION__ that evaluates to the actual symbol of the function instead of its name, so it can be used as a parameter to ParameterIdentifierTuple. You could use the following:

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:56:48 UTC, Simon wrote: And I tried to use your suggestion like this: enum OUTPUT_REPRO_CASE(alias func = __traits(parent, {})) = "build the actual code stuff with"~fullyQualifiedName!func~" and so on"; Which doesn't work. In that case func seems to become

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 19:52:19 UTC, Simon wrote: Thanks for putting up with me! I tried a bunch and it seems like I left out too much code, because I can't get it working 100%. I didn't even know about the q{} syntax, so I didn't think the stuff I left out would matter, but when

Re: How to use inheritance when interfacing with C++ classes?

2021-12-09 Thread Tim via Digitalmars-d-learn
On Thursday, 9 December 2021 at 19:05:08 UTC, rempas wrote: Anyone has an idea? The referenced methods like Fl_Widget::_clear_fullscreen are implemented directly in the header, so the D code also needs the implementation, because it is not included in the compiled library. Methods, which

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

2021-12-13 Thread Tim via Digitalmars-d-learn
On Monday, 13 December 2021 at 15:21:19 UTC, Jan wrote: On Monday, 13 December 2021 at 13:02:50 UTC, Ola Fosheim Grøstad wrote: Yes, I wouldn't want to use it, maybe manual mangling is better, but still painful. ```const A&``` is so common in C++ API's that it really should be supported

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

2021-12-16 Thread Tim via Digitalmars-d-learn
On Thursday, 16 December 2021 at 08:30:14 UTC, Jan wrote: Ok, next problem. Maybe you know the necessary syntax for this one too. C++ ```cpp class Test { public: __declspec(dllexport) static const int const_vars[2]; __declspec(dllexport) static int nonconst_vars[2]; }; const int

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

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 19:28:44 UTC, Jan wrote: C++ ```cpp class Test { public: __declspec(dllexport) static int var; }; int Test::var = 42; ``` D ```cpp extern(C++, class) struct Test { extern (C++) export extern __gshared int var; } ``` (also tried without the duplicate

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

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 15:20:18 UTC, Jan wrote: As I was told linking against functions in DLLs works perfectly, because it is identical to static linking. Linking against global/static variables supposedly differs and that's not handled correctly for DLLs. As I said, I talked to

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

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:01:19 UTC, Jan wrote: Ha, it works indeed! ```cpp extern export __gshared static int var; ``` That's a declaration worthy of C++ ! Fewer keywords would be too usable :D Joking aside, I understood the docs such that `__gshared` actually *is* `static` in

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

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:46:01 UTC, Jan wrote: Btw. should I report this issue somewhere? Is far as I see this isn't logged yet: Yes, it should be reported.

Re: How to use inheritance when interfacing with C++ classes?

2021-12-10 Thread Tim via Digitalmars-d-learn
On Friday, 10 December 2021 at 12:46:07 UTC, rempas wrote: On Thursday, 9 December 2021 at 21:35:14 UTC, Tim wrote: Methods, which are not virtual in C++, also have to be marked final in D, because C++ and D use a different default. Is this a must or just good practices? All virtual methods

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

2021-12-13 Thread Tim via Digitalmars-d-learn
On Monday, 13 December 2021 at 21:17:49 UTC, Jan wrote: Unfortunately no. Maybe the cast would even make it work, but I can't have "A" and "_A" in D as separate types, because the class is supposed to link to C++ functions and thus renaming it from A to _A breaks that. On the other hand I

Re: Structure initializer VS lambda function

2022-12-12 Thread Tim via Digitalmars-d-learn
On Monday, 12 December 2022 at 08:54:33 UTC, realhet wrote: 1. checking inside (on the first hierarchy level inside {}) , => must be a struct initializer ; => must be a lambda no , and no ; => check it from the outside Some statements don't end in a semicolon, so you would also

Threads

2023-03-21 Thread Tim via Digitalmars-d-learn
Hello! I am trying to make a simple multi-threading application. But I get an error when I run the main thread of the program in a thread. The question is: "How to pass arguments from the main thread to the newly created thread of itself". Here is a piece of code: module main; import app;

Re: Threads

2023-03-22 Thread Tim via Digitalmars-d-learn
On Wednesday, 22 March 2023 at 07:16:43 UTC, Kagamin wrote: static is thread local by default. ``` module main; import app; import core.thread; int main(string[] args) { static shared int result; static shared string[] args_copy; static void app_thread() { App app

Re: Threads

2023-03-22 Thread Tim via Digitalmars-d-learn
On Wednesday, 22 March 2023 at 07:16:43 UTC, Kagamin wrote: static is thread local by default. ``` module main; import app; import core.thread; int main(string[] args) { static shared int result; static shared string[] args_copy; static void app_thread() { App app

Re: Recommendations on porting Python to D

2024-04-24 Thread Tim via Digitalmars-d-learn
On Wednesday, 24 April 2024 at 19:50:45 UTC, Chris Piker wrote: I have a somewhat extensive CGI based web service written in Python and I'd like to port it to D. I can do this manually of course, and maybe that's the best way, but for a rough start, is anyone aware of any tools that generate