Re: Windows Console and writing Unicode characters

2021-03-29 Thread Brad via Digitalmars-d-learn
On Monday, 29 March 2021 at 11:53:32 UTC, Adam D. Ruppe wrote: On Monday, 29 March 2021 at 02:12:57 UTC, Brad wrote: [...] You can still import std.stdio and use other functions with just the one overridden. D handles name lookups by just ... well, looking up lol. It starts in the current

Re: What is best way to read and interpret binary files?

2021-03-29 Thread mw via Digitalmars-d-learn
On Monday, 19 November 2018 at 22:32:55 UTC, H. S. Teoh wrote: Actually, the case is unnecessary, because arrays implicitly convert to void[], and pointers are sliceable. So all you need is: SomeStruct myStruct; fd.rawRead(()[0 .. 1]); This works for all POD types. Writing

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Mike Parker via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:21:34 UTC, Marcone wrote: Python dont need pip for run script with imported module. Just need call python. But you need to install the module beforehand. The Pyhton interpreter doesn't fetch modules and install them for you. Neither does dmd.

Re: How to parse JSON in D?

2021-03-29 Thread James Blachly via Digitalmars-d-learn
On 3/29/21 1:44 PM, drug wrote: I use asdf https://code.dlang.org/packages/asdf Also vibe-d https://code.dlang.org/packages/vibe-d has vibe-d:data subpackage Also a happy `asdf` user

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Mar 29, 2021 at 07:28:23PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: > > Why can't I just use: import vibe.vibe; for import packages like Nim > > or Python? Why I still use DUB? > > I don't use dub. Just dmd -i after

Creating a .di file for a custom C library

2021-03-29 Thread Brad via Digitalmars-d-learn
I would like to use an updated version of the Termbox library (written in C) with D. I have the .h file. This is new territory for me (why try something easy - right?). I think I need to create a .di file that corresponds to the .h file. I also suspect that I need to put the library file

Re: What is best way to read and interpret binary files?

2021-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 30, 2021 at 12:32:36AM +, mw via Digitalmars-d-learn wrote: > On Monday, 19 November 2018 at 22:32:55 UTC, H. S. Teoh wrote: > > Actually, the case is unnecessary, because arrays implicitly convert > > to void[], and pointers are sliceable. So all you need is: > > > >

Re: Windows Console and writing Unicode characters

2021-03-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 29 March 2021 at 02:12:57 UTC, Brad wrote: a custom implementation for writeln rather than use the one in stdout module (package?) that would mean any other functions from that package I would want to leverage I would need to include by name. You can still import std.stdio and use

Re: running a d compiler on the Mac Mini with an M1 chip

2021-03-29 Thread Guillaume Piolat via Digitalmars-d-learn
On Friday, 26 March 2021 at 22:41:08 UTC, dan wrote: On Friday, 26 March 2021 at 21:54:20 UTC, rikki cattermole wrote: On 27/03/2021 10:51 AM, dan wrote: Are there any d compilers that run natively on the Mac Mini with an M1 chip? If so, does anybody here have any experience with them that

How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread Gavin Ray via Digitalmars-d-learn
Brief question, is it possible to write this so that the "alias fn" here appears as the final argument? auto my_func(alias fn)(string name, string description, auto otherthing) The above seems to work, since the type of "fn" can vary and it gets called inside of "my_func", but from an

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread Ali Çehreli via Digitalmars-d-learn
On 3/29/21 8:13 AM, Gavin Ray wrote: > Brief question, is it possible to write this so that the "alias fn" here > appears as the final argument? > >auto my_func(alias fn)(string name, string description, auto otherthing) Yes, as a type template parameter but you would have to constrain

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread Paul Backus via Digitalmars-d-learn
On Monday, 29 March 2021 at 16:20:59 UTC, Ali Çehreli wrote: auto myFunc(F)(string name, F func) { // This condition could be a template constraint but they don't // support error messages. static assert (is (Parameters!func == AliasSeq!(string)), "'func' must be a

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread evilrat via Digitalmars-d-learn
On Monday, 29 March 2021 at 15:13:04 UTC, Gavin Ray wrote: Brief question, is it possible to write this so that the "alias fn" here appears as the final argument? auto my_func(alias fn)(string name, string description, auto otherthing) The above seems to work, since the type of "fn" can

How to parse JSON in D?

2021-03-29 Thread tastyminerals via Digitalmars-d-learn
We need to parse a bunch of JSON files. What does D have? It has std.json which is strangely slower than Python json :( Ok, we go to dub repository and search for something that is faster. There are basically two implementations fast.json and stdx.data.json. The first one refuses to work on Mac

Re: How to parse JSON in D?

2021-03-29 Thread drug via Digitalmars-d-learn
I use asdf https://code.dlang.org/packages/asdf Also vibe-d https://code.dlang.org/packages/vibe-d has vibe-d:data subpackage

Re: How to parse JSON in D?

2021-03-29 Thread Imperatorn via Digitalmars-d-learn
On Monday, 29 March 2021 at 17:21:25 UTC, tastyminerals wrote: We need to parse a bunch of JSON files. What does D have? It has std.json which is strangely slower than Python json :( Ok, we go to dub repository and search for something that is faster. There are basically two implementations

Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn
Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB?

Re: It's DUB's "optional": true broken ?

2021-03-29 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 28 March 2021 at 15:52:43 UTC, Zardoz wrote: So, we get this dub.json : { "name": "example", "configurations": [ { "name": "example", "targetType": "library" }, { "name": "unittest", "targetType": "library", "importPaths": ["source",

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Andre Pany via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? In python you also have pip. It is possible to use vibe.d (any dub package) without dub but you have a few manual steps involved.

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote: On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? In python you also have pip. It is possible to use vibe.d (any dub

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote: On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? In python you also have pip. It is possible to use vibe.d (any dub

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? I don't use dub. Just dmd -i after you set up the files in the right place. Not all libraries support that but I only use my own

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Marcone via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote: On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? In python you also have pip. It is possible to use vibe.d (any dub

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Andre Pany via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:21:34 UTC, Marcone wrote: On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote: On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? In python you

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Andre Pany via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:25:06 UTC, Marcone wrote: On Monday, 29 March 2021 at 19:14:41 UTC, Andre Pany wrote: On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? In python you

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread Gavin Ray via Digitalmars-d-learn
On Monday, 29 March 2021 at 16:31:49 UTC, Paul Backus wrote: On Monday, 29 March 2021 at 16:20:59 UTC, Ali Çehreli wrote: auto myFunc(F)(string name, F func) { // This condition could be a template constraint but they don't // support error messages. static assert (is (Parameters!func

Re: How to parse JSON in D?

2021-03-29 Thread Imperatorn via Digitalmars-d-learn
On Monday, 29 March 2021 at 17:21:25 UTC, tastyminerals wrote: We need to parse a bunch of JSON files. What does D have? It has std.json which is strangely slower than Python json :( Ok, we go to dub repository and search for something that is faster. There are basically two implementations

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread evilrat via Digitalmars-d-learn
On Monday, 29 March 2021 at 17:52:13 UTC, Gavin Ray wrote: Trying to read this function signature: void my_func(T, XS)(string a, string b, string c, lazy T function(XS)[] t...) Does this say "Generic void function 'my_func', which takes two generic/type params "T" and "XS", and is a

Re: How to declare "type of function, passed as an argument, which should have it's type inferred"? (or if D had an "any" type)

2021-03-29 Thread Gavin Ray via Digitalmars-d-learn
On Monday, 29 March 2021 at 17:02:40 UTC, evilrat wrote: Also with delegates (lazy), you get the type checks however you must have to declare parameters on call site, which can be PITA in the future when doing refactoring will be necessary. Better plan ahead as the number of changes will

Re: How to parse JSON in D?

2021-03-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/29/21 1:48 PM, Imperatorn wrote: On Monday, 29 March 2021 at 17:21:25 UTC, tastyminerals wrote: We need to parse a bunch of JSON files. What does D have? It has std.json which is strangely slower than Python json :( Ok, we go to dub repository and search for something that is faster.