Re: How to alias

2022-01-14 Thread kyle via Digitalmars-d-learn
On Friday, 14 January 2022 at 17:56:48 UTC, Adam D Ruppe wrote: On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote: [...] alias works in term of compile-time names, not values. This means the `this` value, being run time, gets discarded. [...] Thanks Adam. We need a repository of

How to alias

2022-01-14 Thread kyle via Digitalmars-d-learn
I'm trying to use ```alias``` in an operator overload to reduce typing, but what gets aliased is not what I expect. Tested in DMD v2.098.1-dirty on Windows plus whatever versions of DMD, GDC, and LDC I have installed on Linux. Thanks. ``` struct Broke { double num; import std.traits

Re: abs and minimum values

2021-10-29 Thread kyle via Digitalmars-d-learn
On Friday, 29 October 2021 at 18:19:58 UTC, Salih Dincer wrote: On Thursday, 28 October 2021 at 21:23:15 UTC, kyle wrote: ``` void main() { import std.math : abs, sgn; alias n_type = short; //or int, long, byte, whatever assert(n_type.min == abs(n_type.min));

Re: abs and minimum values

2021-10-28 Thread kyle via Digitalmars-d-learn
On Thursday, 28 October 2021 at 21:23:15 UTC, kyle wrote: ``` void main() { import std.math : abs, sgn; alias n_type = short; //or int, long, byte, whatever assert(n_type.min == abs(n_type.min)); assert(sgn(abs(n_type.min)) == -1); } ``` I stumbled into this fun today. I

abs and minimum values

2021-10-28 Thread kyle via Digitalmars-d-learn
``` void main() { import std.math : abs, sgn; alias n_type = short; //or int, long, byte, whatever assert(n_type.min == abs(n_type.min)); assert(sgn(abs(n_type.min)) == -1); } ``` I stumbled into this fun today. I understand why abs yields a negative value here with overflow

Re: abstract classes and interfaces

2021-09-27 Thread kyle via Digitalmars-d-learn
On Monday, 27 September 2021 at 16:23:49 UTC, Adam D Ruppe wrote: On Monday, 27 September 2021 at 16:20:59 UTC, Steven Schveighoffer wrote: That's a regression. In 2.092.1, it reports: aye known bug here https://issues.dlang.org/show_bug.cgi?id=21321 maybe once dmd can compile C code we'll

abstract classes and interfaces

2021-09-27 Thread kyle via Digitalmars-d-learn
I'm attempting Markdown for the first time so forgive me if that doesn't go well. Consider the following: ```d interface A { bool broken(); } abstract class B : A { } class C : B { } void main() { import std.stdio; C test = new C(); writeln(test); } ``` DMD compiles this

Re: stack out of scope ?

2021-05-16 Thread Kyle via Digitalmars-d-learn
On Sunday, 16 May 2021 at 18:30:49 UTC, Alain De Vos wrote: Is there a list of compiler flags not shown ? ldc2 -help-hidden

Class Allocators

2021-01-31 Thread Kyle via Digitalmars-d-learn
I've been doing some review of Andrei's book which has led me to trying to figure out how placement new works, or doesn't work. The new(address) Type syntax tells me "no allocator for TYPE". I did find information on "Class Allocators" at https://dlang.org/spec/class.html#allocators, but when

Re: ubyte[4] to int

2018-02-15 Thread Kyle via Digitalmars-d-learn
On Thursday, 15 February 2018 at 18:30:57 UTC, Jonathan M Davis wrote: On Thursday, February 15, 2018 17:53:54 Kyle via Digitalmars-d-learn wrote: I want to be able to pass an int to a function, then in the function ensure that the int is little-endian (whether it starts out that way or needs

Re: ubyte[4] to int

2018-02-15 Thread Kyle via Digitalmars-d-learn
"What I'm trying to achieve is to ensure that an int is in little-endiannes" Ignore that last part, whoops.

Re: ubyte[4] to int

2018-02-15 Thread Kyle via Digitalmars-d-learn
On Thursday, 15 February 2018 at 17:43:10 UTC, Jonathan M Davis wrote: On Thursday, February 15, 2018 16:51:05 Kyle via Digitalmars-d-learn wrote: Hi. Is there a convenient way to convert a ubyte[4] into a signed int? I'm having trouble handling the static arrays returned

Re: ubyte[4] to int

2018-02-15 Thread Kyle via Digitalmars-d-learn
On Thursday, 15 February 2018 at 17:25:15 UTC, ketmar wrote: Nicholas Wilson wrote: On Thursday, 15 February 2018 at 16:51:05 UTC, Kyle wrote: Hi. Is there a convenient way to convert a ubyte[4] into a signed int? I'm having trouble handling the static arrays returned by

ubyte[4] to int

2018-02-15 Thread Kyle via Digitalmars-d-learn
Hi. Is there a convenient way to convert a ubyte[4] into a signed int? I'm having trouble handling the static arrays returned by std.bitmanip.nativeToLittleEndian. Is there some magic sauce to make the static arrays into input ranges or something? As a side note, I'm used to using D on Linux

Freeing ENetPacket

2015-11-28 Thread Kyle via Digitalmars-d-learn
Hi, I have a function using the derelict-enet library: void sendUbytes(ENetPeer* dest, ref ubyte[] data) { //create packet ENetPacket* packet = enet_packet_create(cast(ubyte*)data, data.length * ubyte.sizeof, ENET_PACKET_FLAG_RELIABLE); //send packet to peer over channel id 0

Re: Freeing ENetPacket

2015-11-28 Thread Kyle via Digitalmars-d-learn
On Sunday, 29 November 2015 at 01:57:25 UTC, Adam D. Ruppe wrote: .. Are you compiling it as a 64 bit or a 32 bit program? 64 bit. You're probably right, I will take out the explicit destroy and look for a memory leak elsewhere, and adjust for your other suggestions. Thanks for the advice!

Re: DlangUI EditLine question

2015-03-16 Thread Kyle via Digitalmars-d-learn
Thanks! I'll try this out after I get home.

Memoizing methods

2014-12-18 Thread kyle via Digitalmars-d-learn
If you memoize a method inside a class definition using std.functional.memoize is caching done in a per-object manner, or do all objects of this class share cached return values? Thank you.

Interfacing with webcam

2014-09-29 Thread Kyle via Digitalmars-d-learn
Hi, Has anyone successfully used D to capture images from a webcam? Something like what you can do with OpenCV or pygame's camera API? Any idea how I can do this without having to know a lot of complex stuff? Thanks!