Re: std.format with named args

2023-10-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 07:22:41 UTC, Vitaliy Fadeev wrote: On Tuesday, 17 October 2023 at 06:57:07 UTC, Imperatorn wrote: On Tuesday, 17 October 2023 at 06:46:31 UTC, Vitaliy Fadeev wrote: Hi all! I want readable mixin. I want pass variable to string. I want string with named args.

Re: std.format with named args

2023-10-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 06:57:07 UTC, Imperatorn wrote: On Tuesday, 17 October 2023 at 06:46:31 UTC, Vitaliy Fadeev wrote: Hi all! I want readable mixin. I want pass variable to string. I want string with named args. Like this: ```D enum JMP_ADDR_R = "RAX"; mixin( format!"asm {

std.format with named args

2023-10-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
Hi all! I want readable mixin. I want pass variable to string. I want string with named args. Like this: ```D enum JMP_ADDR_R = "RAX"; mixin( format!"asm { jmp [JMP_ADDR_R]; }"( JMP_ADDR_R ));// IT NOT WORK ``` Not this: ```D enum JMP_ADDR_R = "RAX"; mixin(

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

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-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
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 ?

parallelism with delegate

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
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`? async_task.executeInNewThread(); ``` where ```d auto a = new A(); auto

Re: change object class

2023-09-21 Thread Vitaliy Fadeev 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: ... the most correct ``` chip __vtbl ---+ // one of __monitor | id| name | |-> Chip // init |

Re: change object class

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
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 __monitor Sense() idDraw()

Re: change object class

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Thursday, 21 September 2023 at 18:19:47 UTC, Imperatorn wrote: On Sunday, 17 September 2023 at 15:05:59 UTC, 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``` ->

Re: Detect 8-bit alligned type TXY by TX,TY.

2023-09-19 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Tuesday, 19 September 2023 at 06:33:25 UTC, Richard (Rikki) Andrew Cattermole wrote: I assume what you are wanting is to get the alignment for a given type? https://dlang.org/spec/property.html#alignof If instead you want the offset of a given field that's different.

Re: Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Tuesday, 19 September 2023 at 03:53:06 UTC, Richard (Rikki) Andrew Cattermole wrote: There are no operators for this, not that you need one. ```d void func(int numerator, int denominator, out int quotient, out int remainder) { quotient = numerator / denominator; remainder =

Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Vitaliy Fadeev via Digitalmars-d-learn
What D function or D operator does this? ```asm IDIV EAX, r/m32 ``` ``` IDIV 5, 2 EAX = 2 EDX = 1 ``` and returns (2,1) at once?

dlang custom keyword for struct/class

2023-09-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
Is it possible to write like this in D? ```d struct Message { ulong timestamp; } Message LongMessage { ubyte[255] s; } // // it mean // // struct LongMessage // { // Message _super; // alias _super this; // ubyte[255] s; // } // // or // // struct LongMessage // { //

Re: change object class

2023-09-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Sunday, 17 September 2023 at 15:05:59 UTC, Vitaliy Fadeev wrote: ... Playground: https://run.dlang.io/is/hjcLCk

change object class

2023-09-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
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 this.__vptr = typeid(CLS).vtbl.ptr;

Re: unique_ptr | Unique for autoclose handle

2022-12-16 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Thursday, 15 December 2022 at 06:08:32 UTC, Vitaliy Fadeev wrote: On Wednesday, 14 December 2022 at 17:44:05 UTC, Ali Çehreli wrote: On 12/14/22 09:41, Ali Çehreli wrote: > // According to documentation, the handler must be created dynamically: > // We make a unique owner for it:

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 17:44:05 UTC, Ali Çehreli wrote: On 12/14/22 09:41, Ali Çehreli wrote: > // According to documentation, the handler must be created dynamically: > // We make a unique owner for it: Last try is customized **std.typecons.Unique**: ``` module

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 17:41:07 UTC, Ali Çehreli wrote: On 12/14/22 05:58, Vitaliy Fadeev wrote: > On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: >> How to define HANDLE var ? What to return from procedure? How to call >> CloseHandle( h ) when variable

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: How to define HANDLE var ? What to return from procedure? How to call CloseHandle( h ) when variable destroyed? I was trying **std.typecons.Unique**. But where I must put **CloseHandle( h )** ? I was trying

Re: write struct as raw data to file

2021-09-27 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Monday, 27 September 2021 at 13:45:19 UTC, Paul wrote: Vitaliy, Thanks for your assistance. I was looking at your serialization package. Is your example correct? struct MyStruct { ubyte mybyte1; @NoCereal uint nocereal1; //won't be serialised @Bits!4 ubyte

Re: write struct as raw data to file

2021-09-26 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Sunday, 26 September 2021 at 15:09:38 UTC, Paul wrote: Is there way to write the myStruct data to the file in a single statement...or two? Thanks for any assistance. Header[1] header; void readFileHeader( ref File f ) { f.rawRead( header ); }