Re: Sorting arrays of objects, for instance JSONValue's?

2025-07-22 Thread Andy Valencia via Digitalmars-d-learn
On Tuesday, 22 July 2025 at 21:24:04 UTC, Andy Valencia wrote: I'm trying to convince the library's sort() to order an array of JSON objects, where the "name" field is the key for the sort. The following is the closest I've come, but it's not very close! Closer than I thought. I just had to

Sorting arrays of objects, for instance JSONValue's?

2025-07-22 Thread Andy Valencia via Digitalmars-d-learn
I'm trying to convince the library's sort() to order an array of JSON objects, where the "name" field is the key for the sort. The following is the closest I've come, but it's not very close! TIA (as always), Andy ```d import std.json : JSONValue; import std.algorithm.sorting : sort; void ma

Re: python like datastructures as databases code examples

2025-07-22 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 22 July 2025 at 07:32:00 UTC, Serg Gini wrote: On Monday, 21 July 2025 at 16:13:44 UTC, monkyyy wrote: On Monday, 21 July 2025 at 14:56:41 UTC, Serg Gini wrote: But array doesn't look right.. If you want a balanced ("always sorted") structure with "filter" (ability to make some req

Re: python like datastructures as databases code examples

2025-07-22 Thread Serg Gini via Digitalmars-d-learn
On Monday, 21 July 2025 at 16:13:44 UTC, monkyyy wrote: On Monday, 21 July 2025 at 14:56:41 UTC, Serg Gini wrote: But array doesn't look right.. If you want a balanced ("always sorted") structure with "filter" (ability to make some requests for the data) - this looks more like some Tree struct

Re: How to use D on M2 macOS?

2025-07-21 Thread Sergey via Digitalmars-d-learn
On Monday, 21 July 2025 at 17:21:58 UTC, Albert wrote: On Monday, 21 July 2025 at 17:08:17 UTC, Albert wrote: How do I build & run the executable though? Anyway with some perseverance I managed to build & run hello world app. Thank you guys for your help. Though I do think D could do so muc

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 17:08:17 UTC, Albert wrote: How do I build & run the executable though? Anyway with some perseverance I managed to build & run hello world app. Thank you guys for your help. Though I do think D could do so much better with onboarding first time users...

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 16:42:31 UTC, Albert wrote: Sorry to be blunt, but not great first impression so far. I'm still trying to make this work, but stuck with no clue... I think setting sodlib path in settings helped somewhat. At least errors are gone and seems to have detected the build

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 16:24:31 UTC, Luna wrote: The script works by adding a special startup script to your shell session; as such you may need to restart your mac for it to fully work. I've tried everything I can think of, now getting the following errors: ``` Could not initialize dub

Re: How to use D on M2 macOS?

2025-07-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:25:57 UTC, Albert wrote: Thanks, how do I get the beta/nightly version? Only one I see is 0.23.1 from 2021. Thanks It's an option in the code-d extension settings.

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:32:49 UTC, Albert wrote: On Monday, 21 July 2025 at 14:16:29 UTC, Luna wrote: [...] Thank you. This seems to have worked better! Though I am still getting errors: ``` Could not initialize DCD for ``` and in the output get a lot of: ``` 2025-07-21T15:30:59.455

Re: python like datastructures as databases code examples

2025-07-21 Thread monkyyy via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:56:41 UTC, Serg Gini wrote: But array doesn't look right.. If you want a balanced ("always sorted") structure with "filter" (ability to make some requests for the data) - this looks more like some Tree structure Your thinking in classical theory and textbook read

Re: python like datastructures as databases code examples

2025-07-21 Thread Serg Gini via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:15:07 UTC, Monkyyy wrote: On Monday, 21 July 2025 at 08:31:42 UTC, Serg Gini wrote: That filter is not aware of the data structure nor is that array maintaining a sort I'm not sure what you are trying to do. But array doesn't look right.. If you want a balanced (

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:16:29 UTC, Luna wrote: The script I posted automates some of these steps by the way; so you'll just have to set the paths correctly in the plugin (/opt/SDKs/serve-d/bin/serve-d, /opt/SDKs/dcd/bin/dcd-server, /opt/SDKs/dcd/bin/dcd-client); then set the serve-d versi

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:10:44 UTC, Serg Gini wrote: Also don't forget to switch the version of the "code-d" extension to "beta/nightly". Stable is very old and not updating properly. Thanks, how do I get the beta/nightly version? Only one I see is 0.23.1 from 2021. Thanks

Re: How to use D on M2 macOS?

2025-07-21 Thread Serg Gini via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and

Re: python like datastructures as databases code examples

2025-07-21 Thread Monkyyy via Digitalmars-d-learn
On Monday, 21 July 2025 at 08:31:42 UTC, Serg Gini wrote: On Friday, 18 July 2025 at 18:35:40 UTC, monkyyy wrote: `shapes.filter(isnt:shapeenum.isstatic)` https://forum.dlang.org/thread/apbcqxiifbsqdlrsl...@forum.dlang.org I know its possible to make complex, datastructure aware filters, but I

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:10:44 UTC, Serg Gini wrote: On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: [...] I agree with Luna that installing from official GitHub Releases are the easiest way. There is also this project: https://code.dlang.org/packages/ldcup regarding serve-d -

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:52:52 UTC, Luna wrote: On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile ev

How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and dub (nowhere on the download page did it even mention t

Re: python like datastructures as databases code examples

2025-07-21 Thread Serg Gini via Digitalmars-d-learn
On Friday, 18 July 2025 at 18:35:40 UTC, monkyyy wrote: `shapes.filter(isnt:shapeenum.isstatic)` https://forum.dlang.org/thread/apbcqxiifbsqdlrsl...@forum.dlang.org I know its possible to make complex, datastructure aware filters, but I never done it what patterns do people use? lets say you

Re: stdInputRange

2025-07-20 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 20:26:02 UTC, Salih Dincer wrote: I want the program to end with the F6 key on my keyboard instead of the tilde. I use Windows as the platform. Thank you for all your responses. I checked the ASCII table, and 0x1A is indeed the character I was looking for. I'm not su

Re: stdInputRange

2025-07-20 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 21:59:48 UTC, Steven Schveighoffer wrote: There is no F6 Unicode character. Are you seeing tildes when you press F6 and thinking it’s an actual tilde in the stream? When I press the F6 key, ^Z characters appear on the screen. I want the program to terminate using t

Re: stdInputRange

2025-07-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 20:26:02 UTC, Salih Dincer wrote: On Sunday, 20 July 2025 at 12:32:17 UTC, user1234 wrote: No problem here either. Where are you running the program from (embedded terminal in an editor ? a terminal emulator ?). Are you on Windows or Linux ? I want the program to en

Re: stdInputRange

2025-07-20 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 12:32:17 UTC, user1234 wrote: No problem here either. Where are you running the program from (embedded terminal in an editor ? a terminal emulator ?). Are you on Windows or Linux ? I want the program to end with the F6 key on my keyboard instead of the tilde. I use

Re: stdInputRange

2025-07-20 Thread user1234 via Digitalmars-d-learn
On Sunday, 20 July 2025 at 08:46:08 UTC, Salih Dincer wrote: Hello D Language Forum! I’m running the InputRange example below and it dutifully reads from stdin until it spots a tilde, printing each character in every loop iteration. I even tried to break out with F6 but couldn’t get it to sto

Re: stdInputRange

2025-07-20 Thread Dejan Lekic via Digitalmars-d-learn
I've tested your code on the source code itself and it works as expected: ``` » ./salih2 < salih2.d import std; struct StdinByChar { @property bool empty() { if(isEmpty) return true; if(!hasChar) { auto buff = new char[1]; stdin.rawRead(buff); if (buff[

stdInputRange

2025-07-20 Thread Salih Dincer via Digitalmars-d-learn
Hello D Language Forum! I’m running the InputRange example below and it dutifully reads from stdin until it spots a tilde, printing each character in every loop iteration. I even tried to break out with F6 but couldn’t get it to stop. Curiously, swapping the tilde for the '\t' character makes

Re: Audio file metadata parser?

2025-07-18 Thread Andy Valencia via Digitalmars-d-learn
On Saturday, 19 July 2025 at 00:23:28 UTC, Jonathan M Davis wrote: If you're looking to operate on tags in audio files, then there's https://code.dlang.org/packages/taglib-d, which might do what you need, but I don't know much about it, so I can't say for sure. Thank you! That handles my ne

Re: Didn't take this newbie long to hit the first roadblock

2025-07-18 Thread kp via Digitalmars-d-learn
On Saturday, 19 July 2025 at 03:01:51 UTC, Richard (Rikki) Andrew Cattermole wrote: A quick look for dpq2 shows that by default it is configured to use a static binding to PostgreSQL client library. https://github.com/denizzzka/dpq2/blob/master/dub.json#L20 It explicitly adds a shared library

Re: Didn't take this newbie long to hit the first roadblock

2025-07-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
A quick look for dpq2 shows that by default it is configured to use a static binding to PostgreSQL client library. https://github.com/denizzzka/dpq2/blob/master/dub.json#L20 It explicitly adds a shared library dependency on it (``libs`` directive). Which is appropriate if you are on a posix sy

Didn't take this newbie long to hit the first roadblock

2025-07-18 Thread kp via Digitalmars-d-learn
There isn't a pg.lib file in my PG17 installation on Win11 Pro - the closest I see is postgres.lib. What did I miss? - D source code import dpq2; import std.stdio; void main() { // Adjust credentials as needed

Re: Audio file metadata parser?

2025-07-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 18, 2025 4:47:04 PM Mountain Daylight Time Andy Valencia via Digitalmars-d-learn wrote: > Is anyone aware of a library like "tinytag" (a Python module)? > > https://github.com/devsnd/tinytag > > I guess I'll wrestle with porting it to dlang

Audio file metadata parser?

2025-07-18 Thread Andy Valencia via Digitalmars-d-learn
Is anyone aware of a library like "tinytag" (a Python module)? https://github.com/devsnd/tinytag I guess I'll wrestle with porting it to dlang if there's nothing available. tinytag is nice, because it handles wav/ogg/flac/opus/mp3 uniformly. Thanks, Andy

Re: Minimal environment for linking Win32 windowed 64bit exes usind LDC2

2025-07-18 Thread realhet via Digitalmars-d-learn
On Friday, 18 July 2025 at 16:58:13 UTC, Luna wrote: On Friday, 18 July 2025 at 16:50:07 UTC, realhet wrote: On Friday, 18 July 2025 at 15:42:23 UTC, realhet wrote: On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote: ldc has libs in lib/mingw libcmt and co are a part of the Windows SDK.

python like datastructures as databases code examples

2025-07-18 Thread monkyyy via Digitalmars-d-learn
`shapes.filter(isnt:shapeenum.isstatic)` https://forum.dlang.org/thread/apbcqxiifbsqdlrsl...@forum.dlang.org I know its possible to make complex, datastructure aware filters, but I never done it what patterns do people use? lets say you have an always sorted array and the user is asking for v

Re: Minimal environment for linking Win32 windowed 64bit exes usind LDC2

2025-07-18 Thread Luna via Digitalmars-d-learn
On Friday, 18 July 2025 at 16:50:07 UTC, realhet wrote: On Friday, 18 July 2025 at 15:42:23 UTC, realhet wrote: On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote: ldc has libs in lib/mingw Ok I was doing too much: I uninstalled the whole sdk and it turned out It works miraculously just

Re: Minimal environment for linking Win32 windowed 64bit exes usind LDC2

2025-07-18 Thread realhet via Digitalmars-d-learn
On Friday, 18 July 2025 at 15:42:23 UTC, realhet wrote: On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote: ldc has libs in lib/mingw Ok I was doing too much: I uninstalled the whole sdk and it turned out It works miraculously just by itself: `ldc2 win32_app.d -L/subsystem:windows` as si

Re: Minimal environment for linking Win32 windowed 64bit exes usind LDC2

2025-07-18 Thread realhet via Digitalmars-d-learn
On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote: ldc has libs in lib/mingw Please help me how to use it. Currently I managed to compile a very simple example, after installing win10 sdk: I was happy that I don't even need to pass --m64 --line-internally Because it was defaulted. I onl

Re: Minimal environment for linking Win32 windowed 64bit exes usind LDC2

2025-07-18 Thread Kagamin via Digitalmars-d-learn
ldc has libs in lib/mingw

Minimal environment for linking Win32 windowed 64bit exes usind LDC2

2025-07-18 Thread realhet via Digitalmars-d-learn
Hello, What are the minimal environment to do generate win32 64bit windoswed exe's nowadays? Can I do it with only these two? - LDC2 release - and a few static lib files extracted from the windows 10 sdk Is it right? Is there a way to avoid that 2 gigabytes of SDK somehow? Is it possible to a

Re: void[] vs ubyte[] - differences?

2025-07-18 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 17 July 2025 at 18:56:08 UTC, Dukc wrote: - You won't be able to do much anything with `void[]` in `@safe` code. Thanks, I realized that was missing from the docs. Copying into `void[]` is not allowed in @safe code. https://github.com/dlang/dlang.org/pull/4262

Re: void[] vs ubyte[] - differences?

2025-07-17 Thread Dukc via Digitalmars-d-learn
On Wednesday, 16 July 2025 at 13:29:01 UTC, z wrote: I also see this in the language documentation : ``` A void array cannot be indexed. ``` But i can slice it just fine in DMD 2.111... You can _slice_ it, meaning, getting a subarray out of it. However, _indexing_ means getting a single elemen

Re: void[] vs ubyte[] - differences?

2025-07-17 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 17 July 2025 at 16:26:43 UTC, Nick Treleaven wrote: Perhaps there should be an entry for `void` in the types page. A `void` value cannot be accessed. `void.sizeof` is 1 so that a void array can have length equivalent to the number of bytes in the array. https://github.com/dlang/d

Re: void[] vs ubyte[] - differences?

2025-07-17 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 16 July 2025 at 13:29:01 UTC, z wrote: I also see this in the language documentation : ``` A void array cannot be indexed. ``` But i can slice it just fine in DMD 2.111... Is this by design or is there a hole in the language specification? The sentence before says: Array indice

Re: void[] vs ubyte[] - differences?

2025-07-16 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 16, 2025 at 01:29:01PM +, z via Digitalmars-d-learn wrote: [...] > I also see this in the language documentation : > ``` > A void array cannot be indexed. > ``` > But i can slice it just fine in DMD 2.111... Probably an oversight. > Is this by design or is t

void[] vs ubyte[] - differences?

2025-07-16 Thread z via Digitalmars-d-learn
```D import std; void main() { void[] a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0x12345678]; void[] b = cast(ubyte[])[0, 1, 2, 3, 4, 5, 6, 7, 8]; ubyte[] c = cast(ubyte[])(cast(void[])[0, 1, 2, 3, 4, 5, 6, 7, 8,0x12345678]); ubyte[] d = [0, 1, 2, 3, 4, 5, 6, 7, 8]; void[] e = cast(uby

Re: Is there some kind of Blocking Queue for D?

2025-07-15 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 10 July 2025 at 23:57:48 UTC, Ali Çehreli wrote: On 7/10/25 7:28 AM, Bienlein wrote: > some blockinglist wrapper around slist I would try std.concurrency first because its message queue is a blocking queue anyway if you limit the size with setMaxMailboxSize(). I have some example

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 12 July 2025 at 23:55:39 UTC, Ali Çehreli wrote: On 7/11/25 11:36 PM, Bienlein wrote: > Unhappily class MessageBox is private and therefore cannot be reused. Ah! :) That's one more data point against 'private', that little feature that helps with nothing. I don't know what langua

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 13, 2025 1:45:01 PM Mountain Daylight Time Ali Çehreli via Digitalmars-d-learn wrote: > On 7/12/25 5:35 PM, Jonathan M Davis wrote: > > On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali > Çehreli via Digitalmars-d-learn wrote: > Anything can b

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Ali Çehreli via Digitalmars-d-learn
On 7/12/25 5:35 PM, Jonathan M Davis wrote: > On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali Çehreli via Digitalmars-d-learn wrote: >> On 7/11/25 11:36 PM, Bienlein wrote: >> >> > Unhappily class MessageBox is private and therefore cannot be reused.

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 13, 2025 8:38:08 AM Mountain Daylight Time H. S. Teoh via Digitalmars-d-learn wrote: > On Sat, Jul 12, 2025 at 06:35:42PM -0600, Jonathan M Davis via > Digitalmars-d-learn wrote: > > On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali Çehreli > >

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 13, 2025 5:00:12 AM Mountain Daylight Time Bienlein via Digitalmars-d-learn wrote: > On Sunday, 13 July 2025 at 00:35:42 UTC, Jonathan M Davis wrote: > > > Whereas I think that using private makes perfect sense when you > > want something to be an implementatio

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jul 12, 2025 at 06:35:42PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: > On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali Çehreli via > Digitalmars-d-learn wrote: [...] > > Meanwhile, engineers like you suffer because of 'private'. I pic

Re: result of FFT

2025-07-13 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote: What do the 4096 resulting complex numbers represent Bin 0 is energy at 0Hz Bin 1 to 2047 are energy at (bin * samplingRate / 4096) hz Bin 2048 is energy at Nyquist frequency Bin 2049 to 4095 are the energy for negative frequencies and co

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 10 July 2025 at 09:22:30 UTC, Bienlein wrote: Hello, I'm looking for some kind of blocking queue for D, that is if the queue is empty the thread doing a take on the queue is blocked until an item has been added to the queue. Couldn't find anything in the standard library. Thank

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Renato Athaydes via Digitalmars-d-learn
On Saturday, 12 July 2025 at 23:55:39 UTC, Ali Çehreli wrote: On 7/11/25 11:36 PM, Bienlein wrote: The only thing 'private' achieves is this: You don't want your users to be disappointed when they go out of their way to use features that they are advised not to use, and those features behave

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Bienlein via Digitalmars-d-learn
On Sunday, 13 July 2025 at 00:35:42 UTC, Jonathan M Davis wrote: Whereas I think that using private makes perfect sense when you want something to be an implementation detail. Exposing it means that you have to deal with someone using it, you have to design its API for public use, and you can'

Re: Is there some kind of Blocking Queue for D?

2025-07-12 Thread monkyyy via Digitalmars-d-learn
On Sunday, 13 July 2025 at 00:35:42 UTC, Jonathan M Davis wrote: And when the code is open source, if someone wants to use it, they can always just copy it into their own code and do whatever they want with it Not necessarily true, part of the issue with autodecoding is that string.front is

Re: Is there some kind of Blocking Queue for D?

2025-07-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali Çehreli via Digitalmars-d-learn wrote: > On 7/11/25 11:36 PM, Bienlein wrote: > > > Unhappily class MessageBox is private and therefore cannot be reused. > > Ah! :) That's one more data point against 'p

Re: Is there some kind of Blocking Queue for D?

2025-07-12 Thread Ali Çehreli via Digitalmars-d-learn
On 7/11/25 11:36 PM, Bienlein wrote: > Unhappily class MessageBox is private and therefore cannot be reused. Ah! :) That's one more data point against 'private', that little feature that helps with nothing. I don't know what language invented it but I wouldn't be surprised if it came to D from

Re: Is there some kind of Blocking Queue for D?

2025-07-11 Thread Bienlein via Digitalmars-d-learn
On Thursday, 10 July 2025 at 23:57:48 UTC, Ali Çehreli wrote: On 7/10/25 7:28 AM, Bienlein wrote: > some blockinglist wrapper around slist I would try std.concurrency first because its message queue is a blocking queue anyway if you limit the size with setMaxMailboxSize(). I have some example

Re: basic pointer question

2025-07-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 11, 2025 at 10:17:02PM +, WhatMeWorry via Digitalmars-d-learn wrote: > ``` > // working function > > SDL_Texture* changeTextureAccess(SDL_Texture *texture, SDL_TextureAccess > newAccess) > { > // pertinent code only > texture = createTextu

Re: basic pointer question

2025-07-11 Thread Luna via Digitalmars-d-learn
On Friday, 11 July 2025 at 22:17:02 UTC, WhatMeWorry wrote: ``` // working function SDL_Texture* changeTextureAccess(SDL_Texture *texture, SDL_TextureAccess newAccess) { // pertinent code only texture = createTexture(renderer, pixelFormat, newAccess, width, height); return textur

basic pointer question

2025-07-11 Thread WhatMeWorry via Digitalmars-d-learn
``` // working function SDL_Texture* changeTextureAccess(SDL_Texture *texture, SDL_TextureAccess newAccess) { // pertinent code only texture = createTexture(renderer, pixelFormat, newAccess, width, height); return texture; } ``` The above function is working for me when I call it

Re: Is there some kind of Blocking Queue for D?

2025-07-10 Thread Ali Çehreli via Digitalmars-d-learn
On 7/10/25 7:28 AM, Bienlein wrote: > some blockinglist wrapper around slist I would try std.concurrency first because its message queue is a blocking queue anyway if you limit the size with setMaxMailboxSize(). I have some examples of std.concurrency here: https://ddili.org/ders/d.en/conc

Re: Is there some kind of Blocking Queue for D?

2025-07-10 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 10 July 2025 at 14:28:31 UTC, Bienlein wrote: Thanks, Jonathan. The send and receive functions might do the job for some specific purpose, but I would like to have some general blockinglist class like an abstract data type. It sounds like you have in mind shared memory coding tech

Re: Is there some kind of Blocking Queue for D?

2025-07-10 Thread Bienlein via Digitalmars-d-learn
Thanks, Jonathan. The send and receive functions might do the job for some specific purpose, but I would like to have some general blockinglist class like an abstract data type. I'm following the D forum for quite a while, but have so far only written little code in D mostly in order to better

Re: Is there some kind of Blocking Queue for D?

2025-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 10, 2025 3:22:30 AM Mountain Daylight Time Bienlein via Digitalmars-d-learn wrote: > Hello, > > I'm looking for some kind of blocking queue for D, that is if the > queue is empty the thread doing a take on the queue is blocked > until an item has bee

Is there some kind of Blocking Queue for D?

2025-07-10 Thread Bienlein via Digitalmars-d-learn
Hello, I'm looking for some kind of blocking queue for D, that is if the queue is empty the thread doing a take on the queue is blocked until an item has been added to the queue. Couldn't find anything in the standard library. Thank you, Oliver

Re: result of FFT

2025-07-10 Thread claptrap via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote: Hi, I'm writing a program where I'm trying to decode DTMF tones. I already completed the wave file decoder and I know I'm supposed to use an FFT to transform the samples from time domain to frequency domain but I'm stuck on determining w

Re: result of FFT

2025-07-09 Thread Andy Valencia via Digitalmars-d-learn
On Wednesday, 9 July 2025 at 19:39:43 UTC, Matthew wrote: Checking the closest bins to each frequency seems to work well, at least with clean sound from a wav file. It remains to be seen how it fares against noisy real life signals. I'll likely need a window function or interpolation but this

Re: result of FFT

2025-07-09 Thread Matthew via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 19:39:37 UTC, Dennis wrote: The magnitude of each element (computed with `std.complex.abs`) corresponds to the amplitude of each frequency component, the angle in the complex plane represents the phase (computed with `std.complex.arg` in radians). This is what I pi

Re: result of FFT

2025-07-09 Thread Timon Gehr via Digitalmars-d-learn
On 7/8/25 23:06, Timon Gehr wrote: auto fToWave(R)(size_t N,R coefficients_f){     return iota(N/2+1).map!(j=>     tuple!("magnitude","frequency","phase")(     (j==N/2?1.0:2.0)*abs(coefficients_f[j]).re,     K(j)*sample_rate/N,     std.complex.log(coefficients_f[

Re: result of FFT

2025-07-09 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote: Hi, I'm writing a program where I'm trying to decode DTMF tones. I already completed the wave file decoder and I know I'm supposed to use an FFT to transform the samples from time domain to frequency domain but I'm stuck on determining w

Re: result of FFT

2025-07-09 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 21:10:35 UTC, Serg Gini wrote: On Tuesday, 8 July 2025 at 19:59:39 UTC, Serg Gini wrote: On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote: From my perspective - solve it in NumPy will be safer approach, but it should be doable in D as well. Or even better - cr

Re: result of FFT

2025-07-08 Thread Serg Gini via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 19:59:39 UTC, Serg Gini wrote: On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote: From my perspective - solve it in NumPy will be safer approach, but it should be doable in D as well. Or even better - create D library for this :) It seems (after fast googling) t

Re: result of FFT

2025-07-08 Thread Timon Gehr via Digitalmars-d-learn
On 7/8/25 20:11, Matthew wrote: Hi, I'm writing a program where I'm trying to decode DTMF tones. I already completed the wave file decoder and I know I'm supposed to use an FFT to transform the samples from time domain to frequency domain but I'm stuck on determining which of the DTMF frequen

Re: result of FFT

2025-07-08 Thread Serg Gini via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote: Hi, What do the 4096 resulting complex numbers represent? How should I use the result to check whether the 1209Hz, 1336Hz, 1477Hz, or 1633Hz tones are present in that part of the sound? Thanks, Matthew The result of FFT should be the s

Re: result of FFT

2025-07-08 Thread Dennis via Digitalmars-d-learn
On Tuesday, 8 July 2025 at 18:11:27 UTC, Matthew wrote: I can't figure out how the 4096 results of the FFT relate to the frequencies in the input. I tried taking the magnitude of each element, That's correct! What do the 4096 resulting complex numbers represent? The magnitude of each elem

result of FFT

2025-07-08 Thread Matthew via Digitalmars-d-learn
Hi, I'm writing a program where I'm trying to decode DTMF tones. I already completed the wave file decoder and I know I'm supposed to use an FFT to transform the samples from time domain to frequency domain but I'm stuck on determining which of the DTMF frequencies are present. Consider the

Re: Looking for a simple GUI library that works with Vulkan on SDL2

2025-07-08 Thread Luna via Digitalmars-d-learn
On Wednesday, 19 February 2025 at 15:21:19 UTC, Danny Arends wrote: Hey all, I am looking to integrate a GUI library like IMgui / Nuklear into my app that uses Vulkan within SDL2 for rendering so that it can run on Windows, Linux, and Android (https://github.com/DannyArends/CalderaD). I've

Diamond Rings for Women: A Symbol of Elegance and Timeless Beauty

2025-07-07 Thread luckyar via Digitalmars-d-learn
When it comes to timeless elegance and symbolic value, few pieces of jewelry can match the allure of diamond rings for women. For centuries, diamonds have been treasured for their beauty, rarity, and the emotions they represent. From engagement rings to anniversary gifts and fashion statements,

Re: CTFE and return statement from delegate

2025-07-06 Thread Rajesh via Digitalmars-d-learn
On Thursday, 3 July 2025 at 15:29:53 UTC, Nick Treleaven wrote: On Monday, 30 June 2025 at 04:51:58 UTC, Rajesh wrote: On Sunday, 29 June 2025 at 21:56:19 UTC, 0xEAB wrote: On Sunday, 29 June 2025 at 13:06:38 UTC, Rajesh wrote: Is there a restriction that I cannot call **return** from foreach

Re: Exception when creating a Thread with Windows

2025-07-05 Thread stef via Digitalmars-d-learn
On Saturday, 5 July 2025 at 10:52:21 UTC, Steven Schveighoffer wrote: By using WinMain, You are bypassing the runtime startup. Check out this article: https://wiki.dlang.org/D_for_Win32 -Steve Thank you very much. It's working perfectly. stef

Re: Exception when creating a Thread with Windows

2025-07-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 5 July 2025 at 10:39:13 UTC, stef wrote: Hello, I'm totally new using D. I'm trying to create a thread using this code: ```d … extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) … ``` I'm testing this program using

Exception when creating a Thread with Windows

2025-07-05 Thread stef via Digitalmars-d-learn
Hello, I'm totally new using D. I'm trying to create a thread using this code: ```d import std.stdio; import core.thread; import core.time; import std.format; import core.stdc.stdio; void myThread() { for (int i = 0; i < 5; i++) { writefln("Message from secon

Re: Why this doesn't produce an error or works as expected?

2025-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 5, 2025 2:19:11 AM Mountain Daylight Time partypooper via Digitalmars-d-learn wrote: > On Saturday, 5 July 2025 at 08:08:08 UTC, Jonathan M Davis wrote: > > On Friday, July 4, 2025 12:04:55 PM Mountain Daylight Time > > partypooper via Digitalmar

Re: Why this doesn't produce an error or works as expected?

2025-07-05 Thread partypooper via Digitalmars-d-learn
On Saturday, 5 July 2025 at 08:08:08 UTC, Jonathan M Davis wrote: On Friday, July 4, 2025 12:04:55 PM Mountain Daylight Time partypooper via Digitalmars-d-learn wrote: [...] The only time that a setter function would be triggered would be assignment such as [...] Thanks for your thorough

Re: Why this doesn't produce an error or works as expected?

2025-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 4, 2025 12:04:55 PM Mountain Daylight Time partypooper via Digitalmars-d-learn wrote: > On Friday, 4 July 2025 at 17:34:59 UTC, monkyyy wrote: > > On Friday, 4 July 2025 at 17:15:48 UTC, partypooper wrote: > > if you add ref to line 28 it works; there wont be a rea

Accessing the parents arguments from a child function call

2025-07-04 Thread monkyyy via Digitalmars-d-learn
```d auto bar(int i){ foo() } unittest{ bar(3); } ``` Given any definition of foo, any compiler bugs, how would you detect the `3` from `foo`? ___ My attempts at scanning the call stack didn't work but for anyone attempting it, I believe this breakdown of control flow may be part of the

Re: Why this doesn't produce an error or works as expected?

2025-07-04 Thread partypooper via Digitalmars-d-learn
On Friday, 4 July 2025 at 18:04:55 UTC, partypooper wrote: It doesn't work. Or it works even worse: changing _pos, but not _dest. What is going on is that on `+=` it for some reason invokes "getter", not "setter". I specifically omitted "ref", because I already have known of that behavior. In

Re: Why this doesn't produce an error or works as expected?

2025-07-04 Thread partypooper via Digitalmars-d-learn
On Friday, 4 July 2025 at 17:34:59 UTC, monkyyy wrote: On Friday, 4 July 2025 at 17:15:48 UTC, partypooper wrote: if you add ref to line 28 it works; there wont be a reasonable way to make an error happen, you just have to know when to do refness It doesn't work. Or it works even worse: chang

Re: why is the behavior of pointers to 0 width doing this?

2025-07-04 Thread monkyyy via Digitalmars-d-learn
On Friday, 4 July 2025 at 08:17:34 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d import std.stdio; __gshared int literal; void main() { int[0] callstack; (&callstack+literal).writeln; } ``` ```asm _Dmain: .Lfunc_begin0: .file 1 "/" "app/example.d" .loc1 5 0

Re: Why this doesn't produce an error or works as expected?

2025-07-04 Thread monkyyy via Digitalmars-d-learn
On Friday, 4 July 2025 at 17:15:48 UTC, partypooper wrote: ```d struct Vector { float x, y; Vector opBinary(string op)(inout Vector rhs) const if (op == "+") { return Vector(mixin("x", op, "rhs.x"), mixin("y", op, "rhs.y"),); } ref Vector opOpAssign(string op)(in

Why this doesn't produce an error or works as expected?

2025-07-04 Thread partypooper via Digitalmars-d-learn
```d struct Vector { float x, y; Vector opBinary(string op)(inout Vector rhs) const if (op == "+") { return Vector(mixin("x", op, "rhs.x"), mixin("y", op, "rhs.y"),); } ref Vector opOpAssign(string op)(inout Vector rhs) if (op == "+" || op == "-") {

Re: Interact with local variables in asm block

2025-07-04 Thread confuzzled via Digitalmars-d-learn
On 7/5/25 1:06 AM, confuzzled wrote: ulong rdtsc() {     ulong result;     uint* res = cast(uint*) &result;     asm {     rdtsc;  // Puts result in edx:eax     // Cast our ulong's address to a 32-bit integer pointer     // and move the register values into the correct memory lo

Re: Looking for a simple GUI library that works with Vulkan on SDL2

2025-07-04 Thread IchorDev via Digitalmars-d-learn
On Thursday, 20 February 2025 at 10:05:13 UTC, Danny Arends wrote: Running into some weird linker issues within bindbc.common.codegen: ``` /usr/bin/ld: /home/danny/.dub/cache/betterct/~master/build/betterC-debug-gZx8lRyN8EaQ6hq_UuhHCw/betterct.o:(.data._D39TypeInfo_S6bindbc6common7codegen6FnBi

Interact with local variables in asm block

2025-07-04 Thread confuzzled via Digitalmars-d-learn
Good day all, What is the proper way to assign to accomplish this? ulong rdtsc() { ulong result; uint* res = cast(uint*) &result; asm { rdtsc; // Puts result in edx:eax // Cast our ulong's address to a 32-bit integer pointer // and move the register values i

Re: Pointer vs Ref

2025-07-04 Thread confuzzled via Digitalmars-d-learn
On 6/15/25 9:06 AM, Steven Schveighoffer wrote: On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. A ref cannot be a member of a type. But ref can be returned by

  1   2   3   4   5   6   7   8   9   10   >