Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 19:50:17 UTC, Christian Köstlin wrote: On 17.09.23 17:05, Vitaliy Fadeev wrote: Hi! You could model it oop style like this: https://run.dlang.io/is/MJb5Fk This solution might not be to your taste, as it involves interfaces, and classes and objects and garbage

Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 21:37:37 UTC, Imperatorn wrote: On Friday, 22 September 2023 at 14:03:40 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 12:53:28 UTC, Imperatorn wrote: You're basically just describing polymorphism. I can post an example tomorrow, it's midnight here

Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 19:50:17 UTC, Christian Köstlin wrote: another option could be to model your own VTable in a struct like this: https://run.dlang.io/is/3LTjP5 Kind regards, Christian Thank, Christian ! True nice tasty solution with ```VTable```! And further... the project is

Re: odd bit optimized function

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 22:48:34 UTC, claptrap wrote: On Friday, 22 September 2023 at 14:29:08 UTC, Vitaliy Fadeev wrote: x86 first bit check (odd check): ```asm AND EAX, EAX ; update FLAG OF // odd flag JO Label ``` Is there D-Lang operator of optimized library function ? There's

Re: odd bit optimized function

2023-09-22 Thread claptrap via Digitalmars-d-learn
On Friday, 22 September 2023 at 14:29:08 UTC, Vitaliy Fadeev wrote: x86 first bit check (odd check): ```asm AND EAX, EAX ; update FLAG OF // odd flag JO Label ``` Is there D-Lang operator of optimized library function ? There's no "odd" flag, theres the overflow flag "O", and "JO" is jump

Re: Help on array pointers

2023-09-22 Thread Joe--- via Digitalmars-d-learn
On Monday, 18 September 2023 at 02:49:37 UTC, vino wrote: On Sunday, 17 September 2023 at 18:28:36 UTC, Joe wrote: On Friday, 15 September 2023 at 16:55:34 UTC, Vino wrote: [...] [...] char[] invalid = (cast(char*)malloc(char.sizeof * len))[0..len]; This is not the way to go about it.

Re: change object class

2023-09-22 Thread Imperatorn via Digitalmars-d-learn
On Friday, 22 September 2023 at 14:03:40 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 12:53:28 UTC, Imperatorn wrote: On Friday, 22 September 2023 at 03:33:08 UTC, Vitaliy Fadeev wrote: [...] What I mean is, why not use other language constructs like mixins or inheritance with

Re: change object class

2023-09-22 Thread Christian Köstlin via Digitalmars-d-learn
On 17.09.23 17:05, Vitaliy Fadeev wrote: Hi! I want to change a method ```Draw``` on a custom object when the ```MouseIn``` event occurs. This is known as "Change State" of the object: ```Init``` -> ```Hovered```. I want to change the state of an object by changing its class, like this: ```d

Re: Request you advise : isValidFilename

2023-09-22 Thread FeepingCreature via Digitalmars-d-learn
On Friday, 22 September 2023 at 17:52:51 UTC, FeepingCreature wrote: "Integer representation" here refers to the ANSI index or Unicode codepoint, ie. the filename must not contain `\x00` to `\x31`. Er oops, make that `\x00` to `\x1f`.

Re: Request you advise : isValidFilename

2023-09-22 Thread FeepingCreature via Digitalmars-d-learn
On Friday, 22 September 2023 at 17:44:50 UTC, Vino wrote: Hi All, Request you help in understanding why the below code is always returning true when it should return false as per the documentation. Documentation ``` filename must not contain any characters whose integer representation is

Request you advise : isValidFilename

2023-09-22 Thread Vino via Digitalmars-d-learn
Hi All, Request you help in understanding why the below code is always returning true when it should return false as per the documentation. Documentation ``` Checks that the given file or directory name is valid. The maximum length of filename is given by the constant

odd bit optimized function

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
x86 first bit check (odd check): ```asm AND EAX, EAX ; update FLAG OF // odd flag JO Label ``` Is there D-Lang operator of optimized library function ?

Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 12:53:28 UTC, Imperatorn wrote: On Friday, 22 September 2023 at 03:33:08 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 02:51:10 UTC, Vitaliy Fadeev wrote: ... ``` Chip id name Sense() Draw() ``` instance ``` chip = new Chip(); ```

Re: parallelism with delegate

2023-09-22 Thread Imperatorn via Digitalmars-d-learn
On Friday, 22 September 2023 at 04:24:19 UTC, Vitaliy Fadeev wrote: able ? how to use correctly? ```d import std.parallelism; auto async_task = task!fn( args ); // error // Error: no property `opCall` for type `app.A`, did you mean `new A`?

Re: change object class

2023-09-22 Thread Imperatorn via Digitalmars-d-learn
On Friday, 22 September 2023 at 03:33:08 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 02:51:10 UTC, Vitaliy Fadeev wrote: ... ``` Chip id name Sense() Draw() ``` instance ``` chip = new Chip(); ``` compiled to ``` chip __vtbl -> Chip

Re: C to D: please help translate this weird macro

2023-09-22 Thread Ki Rill via Digitalmars-d-learn
On Thursday, 21 September 2023 at 16:50:51 UTC, Imperatorn wrote: On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote: Here is the macro: ```C #define NK_CONTAINER_OF(ptr,type,member)\ (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member))) ```

Re: C to D: please help translate this weird macro

2023-09-22 Thread Ki Rill via Digitalmars-d-learn
On Thursday, 21 September 2023 at 16:28:25 UTC, Nick Treleaven wrote: The 1st argument of `getMember` can just be T, like the original macro. The 2nd argument needs to be a compile-time string. Also the `char*` cast needs to apply to `ptr` before subtracting the offset AFAICS. So

Re: std.file: read, readText and UTF-8 decoding

2023-09-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 22, 2023 12:28:39 AM MDT Uranuz via Digitalmars-d-learn wrote: > OK. Thanks for response. I wish that there it was some API to > handle it "out of the box". Do I need to write some issue or > something in order to not forget about this? You can open an issue if you want,

Re: parallelism with delegate

2023-09-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 21, 2023 10:33:44 PM MDT Vitaliy Fadeev via Digitalmars-d-learn wrote: > On Friday, 22 September 2023 at 04:24:19 UTC, Vitaliy Fadeev > > wrote: > > ... > > Skip this thread. I see solution. > > How to delete missed posts on this forum ? This forum is esentially just a web

Re: std.file: read, readText and UTF-8 decoding

2023-09-22 Thread Uranuz via Digitalmars-d-learn
OK. Thanks for response. I wish that there it was some API to handle it "out of the box". Do I need to write some issue or something in order to not forget about this?