Re: Event struct via registers

2024-08-10 Thread claptrap via Digitalmars-d-learn
On Saturday, 10 August 2024 at 08:18:54 UTC, Vitaliy Fadeev wrote: On Saturday, 10 August 2024 at 08:06:42 UTC, IchorDev wrote: Is your application highly performance critical? Many input event + many internal ui events -> many calls * many objects. Yes, I like the fast, responsive interface

Re: array setting : Whats going in here?

2023-10-07 Thread claptrap via Digitalmars-d-learn
On Saturday, 7 October 2023 at 00:49:39 UTC, H. S. Teoh wrote: On Sat, Oct 07, 2023 at 12:00:48AM +, claptrap via Digitalmars-d-learn wrote: When you write `foo[]` you're taking a slice of the array, and in that case if the lengths of both sides of the assignment don't mat

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: Which function returns a pair after division ? (integer,frac)

2023-09-19 Thread claptrap via Digitalmars-d-learn
On Tuesday, 19 September 2023 at 03:44:18 UTC, Vitaliy Fadeev wrote: 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? If you use LDC it'll automatically optimize that for you https://d.godbolt.org/z/oz4h9ccbP

Re: Drawing a line code

2022-11-06 Thread claptrap via Digitalmars-d-learn
On Sunday, 6 November 2022 at 11:22:26 UTC, Joel wrote: I found some code on the net but haven't been able to get it working properly. I trying to draw with mouse (any direction). this is the classic integer line drawing algorithm... https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#A

Re: Why many programmers don't like GC?

2021-01-14 Thread claptrap via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 20:06:51 UTC, H. S. Teoh wrote: On Wed, Jan 13, 2021 at 06:58:56PM +, Marcone via Digitalmars-d-learn wrote: I've always heard programmers complain about Garbage Collector GC. But I never understood why they complain. What's bad about GC? It's not merely a

Re: Whats going on with this?

2020-10-03 Thread claptrap via Digitalmars-d-learn
On Saturday, 3 October 2020 at 00:15:02 UTC, Steven Schveighoffer wrote: On 10/2/20 7:28 PM, claptrap wrote: Why would putting in the writeln cause it to fail? Is it maybe trying to create the foo at compile time? Yes, it is. Any static initialization of static variables happens at compile

Whats going on with this?

2020-10-02 Thread claptrap via Digitalmars-d-learn
--- import std; import std.stdio; struct Foo { int a = 0, b = 0; this(int[2] vars) { this.a = vars[0]; this.b = vars[1]; //writeln("constructor called"); } } Foo foo = [300,300]; void main() { writeln(foo.a); } --- Compiles and works OK. I cant se

Re: Why private methods cant be virtual?

2020-09-22 Thread claptrap via Digitalmars-d-learn
On Tuesday, 22 September 2020 at 13:19:10 UTC, Daniel Kozak wrote: On Tue, Sep 22, 2020 at 3:05 PM claptrap via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: The thread title is... "Why private methods cant be virtual?" IE Not... "how do I override p

Re: Why private methods cant be virtual?

2020-09-22 Thread claptrap via Digitalmars-d-learn
On Tuesday, 22 September 2020 at 10:23:08 UTC, Daniel Kozak wrote: On Tue, Sep 22, 2020 at 11:06 AM claptrap via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: "Functions marked as final may not be overridden in a derived class, unless they are also private&

Re: Why private methods cant be virtual?

2020-09-22 Thread claptrap via Digitalmars-d-learn
On Tuesday, 22 September 2020 at 00:46:02 UTC, Steven Schveighoffer wrote: On 9/21/20 7:52 PM, H. S. Teoh wrote: On Mon, Sep 21, 2020 at 07:43:30PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] No, it's not a bug. It's intentional. private and package functions are final, a

Why private methods cant be virtual?

2020-09-21 Thread claptrap via Digitalmars-d-learn
Seems like a completely pointless restriction to me. I mean it will only affect other descendent classes declared in the same module, and they can access all the private members anyway, so it's locking the front door but leaving the back door wide open. On the other hand if you actually want a

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-18 Thread claptrap via Digitalmars-d-learn
On Friday, 18 September 2020 at 02:49:30 UTC, Mike Parker wrote: On Thursday, 17 September 2020 at 22:25:47 UTC, claptrap wrote: If enum means manifiest constant, or compile time constant, then it makes more sense, as you allude to in a later post. But 'enum' is a terrible name for that and I

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-17 Thread claptrap via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:56:28 UTC, Mike Parker wrote: On Thursday, 17 September 2020 at 09:44:20 UTC, claptrap wrote: Seriously how it's implemented is irrelevant. And to be clear, my point wasn't about how it's implemented. My point was that: enum { foo = 10; } and enum foo

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-17 Thread claptrap via Digitalmars-d-learn
On Thursday, 17 September 2020 at 01:57:39 UTC, Mike Parker wrote: On Thursday, 17 September 2020 at 00:32:40 UTC, Cecil Ward enum foo is essentially a shortcut for enum { foo }. It’s neither bent out of shape nor twisted. Consider that C++ added the new keyword constexpr for the same thing.

Re: LDC cross-module-inlining

2020-08-09 Thread claptrap via Digitalmars-d-learn
On Sunday, 9 August 2020 at 22:18:13 UTC, Per Nordlöw wrote: Is cross-module-inlining enabled by default in LDC when compiling in release mode or do I have to use explicitly flag for it? I can't find any such flag from the output of neither ldc2 -h nor ldmd2 -h . Johan Engelen ment

dub build=ddox, where the are the docs?

2020-07-06 Thread claptrap via Digitalmars-d-learn
Ok yeah it starts up a server and opens a webpage, great, but where are the docs? Cant find any info on command line switches for dub or ddox on how to get it to just dump the docs in a folder.

Re: opBinary : Static ifs or specialization?

2020-06-24 Thread claptrap via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 00:53:58 UTC, H. S. Teoh wrote: On Tue, Jun 23, 2020 at 11:53:36PM +, claptrap via If your implementations are based on built-in operators, you could use mixins to unify the implementations into one, e.g.: Ah yeah thats useful, to expand a bit what about i

opBinary : Static ifs or specialization?

2020-06-23 Thread claptrap via Digitalmars-d-learn
So you have opBinary and half a dozen operators to implement. Do you use a separate method for each operator or do you have one method and a big static if else if to select code path? I assume they are functionally equivalent? So its just about style?

Should opIndex take precedence over pointer indexing?

2020-06-12 Thread claptrap via Digitalmars-d-learn
struct Foo { float* what; float opIndex(size_t idx) { return what[idx]; } } Foo* foo; float x = foo[idx]; // *** *** (68): Error: cannot implicitly convert expression `foo[cast(ulong)idx]` of type `Foo` to `float` IE, pointer indexing of 'foo' takes precedence over the opIndex of fo