What prevents ImportC from using .h directly?

2024-05-12 Thread Chris Piker via Digitalmars-d-learn
Hi D Import D is working quite well so far. One limitation is that module definitions require a tiny *.c file which is often just: ```C #include ``` Creating this file is trivial and has almost no knock-on effects, except when dealing with single file programs. I have quite a few small

Re: Recommendations on porting Python to D

2024-05-03 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 25 April 2024 at 16:57:53 UTC, mw wrote: On Wednesday, 24 April 2024 at 22:07:41 UTC, Chris Piker wrote: Python-AST to D source converter may already exist? https://github.com/joortcom/eiffel_rename/tree/main/yi A rudimentary converter from (extended) Python to D. Maybe you

Re: Recommendations on porting Python to D

2024-04-25 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 25 April 2024 at 07:04:13 UTC, Sergey wrote: On Wednesday, 24 April 2024 at 22:07:41 UTC, Chris Piker wrote: Python-AST to D source converter may already exist? Another possible way maybe is using C :) Python -> C -> D https://wiki.python.org/moin/PythonImplementations#Compilers

Re: Recommendations on porting Python to D

2024-04-24 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 24 April 2024 at 20:13:26 UTC, Lance Bachmeier wrote: I haven't used Python much in recent years, but my recollection is that Python 2 had an ast module that would spit out the ast for you. Thanks for the pointer! So I ran one of my modules through and generated an AST, and get

Recommendations on porting Python to D

2024-04-24 Thread Chris Piker via Digitalmars-d-learn
Hi D I have a somewhat extensive CGI based web service written in Python and I'd like to port it to D. I can do this manually of course, and maybe that's the best way, but for a rough start, is anyone aware of any tools that generate an abstract syntax tree which could then be converted to

Re: Best way to use large C library in D as of 2024

2024-04-12 Thread Chris Piker via Digitalmars-d-learn
On Monday, 1 April 2024 at 02:08:20 UTC, Lance Bachmeier wrote: On Saturday, 30 March 2024 at 05:01:32 UTC, harakim wrote: It works well if you only need to work with a header. There are still a few rough edges that get in the way if you're compiling the full C sources (I filed bugs for all of

Re: Best way to use large C library in D as of 2024

2024-04-12 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 30 March 2024 at 07:11:49 UTC, Mike Parker wrote: Though I appreciate the sentiment, it's much more effective and efficient for people actually using the feature, and who appreciate it, to write up a blog post about it somewhere and share that on Twitter/Reddit/HN, etc. I would,

Re: Best way to use large C library in D as of 2024

2024-03-26 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 26 March 2024 at 20:19:27 UTC, bachmeier wrote: Should be able to just use it, as described here: https://forum.dlang.org/post/qxctappnigkwvaqak...@forum.dlang.org Create a .c file that includes the header files and then call the functions you need. Wow. **That just worked the

Best way to use large C library in D as of 2024

2024-03-26 Thread Chris Piker via Digitalmars-d-learn
Hi D I have a C library I use for work, it's maintained by an external organization that puts it through a very through test framework. Though source code is supplied, the intended use is to include the header files and link against pre-compiled code. What is the best way, as of 2024 to

SumType structure wrapping seems to fail (dmd v2.105.2)

2023-09-30 Thread Chris Piker via Digitalmars-d-learn
Hi D As suggested in other threads I've tried wrapping a SumType in a structure to add functionality and used `alias ... this` to make assignment, etc. easier. However the following code fails in dmd 2.105.2. ```d import std.sumtype; struct Item{ SumType!(void*, byte[3], ubyte[3],

Re: How to print current type of a SumType?

2023-09-30 Thread Chris Piker via Digitalmars-d-learn
We posted at the same time! Thanks for help nonetheless. I do hope over time, SumTypes get the Ali Çehreli treatment. I keep his book open on my desk all the time.

Re: How to print current type of a SumType?

2023-09-30 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 1 October 2023 at 01:17:50 UTC, Chris Piker wrote: ```d alias Vec3 = SumType!(void* /* invalid vector */, byte[3], short[3], char[][3]); ``` I know it's bad form to reply to my own question, but I think I found a reasonably simple way: ```d string prnType(Vec3 vec){ return

How to print current type of a SumType?

2023-09-30 Thread Chris Piker via Digitalmars-d-learn
Hi D I've a simple question but it's bedeviling me anyway. How do I get a string representation of the current type of a SumType? I'm trying to avoid something like this: ```d alias Vec3 = SumType!(void* /* invalid vector */, byte[3], short[3], char[][3]); string prnType(Vec3 vec){

Re: Recommendation on plotting library

2023-07-22 Thread Chris Piker via Digitalmars-d-learn
Thanks for the both of the long replies. I've ready them twice and will do so again. To focus in on one aspect of D package support: On Saturday, 22 July 2023 at 02:24:08 UTC, Greggor wrote: In general whenever possible I think its better for everyone that stuff is built from source. It

Re: Recommendation on plotting library

2023-07-21 Thread Chris Piker via Digitalmars-d-learn
On Friday, 21 July 2023 at 17:40:25 UTC, Greggor wrote: Up to date versions of Windows 10 should have curl included and dub can run commands before building, so you could try downloading a prebuilt lib for windows via curl. https://everything.curl.dev/get/windows Hey, nice! This might be a

Re: Recommendation on plotting library

2023-07-21 Thread Chris Piker via Digitalmars-d-learn
On Friday, 21 July 2023 at 06:15:10 UTC, Jonathan M Davis wrote: On Thursday, July 20, 2023 10:57:22 PM MDT Chris Piker via Digitalmars-d-learn wrote: Regardless though, dub really isn't designed with packaging anything in mind. Rather, it's designed to build your code as well as pull in D

Re: Recommendation on plotting library

2023-07-20 Thread Chris Piker via Digitalmars-d-learn
On Friday, 21 July 2023 at 02:40:10 UTC, harakim wrote: On Thursday, 20 July 2023 at 02:37:54 UTC, Chris Piker wrote: If you happen upon a basic charting library for D during this hunt, please let me know! Last year, I rolled my own and it got the job done, but I wasn't concerned about how

Re: Pre-import version statements

2023-07-20 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 20 July 2023 at 06:44:30 UTC, Jonathan M Davis wrote: D has nothing equivalent to that. You compile your code with whichever version of dmd (or ldc, gdc, etc.) that you want, and it either compiles or it doesn't. Thanks :) As I developer that doesn't bother me too much, though

Pre-import version statements

2023-07-19 Thread Chris Piker via Digitalmars-d-learn
Hi D In my C code I used to typically put the line: ``` #define _POSIX_C_SOURCE 200112L ``` in the source before importing any standard library headers. Is there something equivalent for phobos? Say `version(phobos2.100)` or similar? I don't particularly need this functionality, just

Re: Recommendation on plotting library

2023-07-19 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 20 July 2023 at 03:58:05 UTC, Andrew wrote: If you're already using python, it's probably best to keep using that. Oh of course. Examples *have* to be provided in python, since that's the default language of science these days. But extra examples don't hurt, and it would be

Recommendation on plotting library

2023-07-19 Thread Chris Piker via Digitalmars-d-learn
Hi D One of my jobs is to release and maintain public data archives from long-running scientific instruments. In order to help people understand how to process the data, sample code is often included with the archive. Recently this has been in the form of short programs that generate a plot

Re: Proper way to handle "alias this" deprecation for classes

2023-05-10 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 10 May 2023 at 20:25:48 UTC, H. S. Teoh wrote: On Wed, May 10, 2023 at 07:56:10PM +, Chris Piker via Digitalmars-d-learn wrote: [...] I also suffer from left/right confusion, and always have to pause to think about which is the right(!) word before uttering it. Oh, I though

Re: Proper way to handle "alias this" deprecation for classes

2023-05-10 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 10 May 2023 at 16:01:40 UTC, H. S. Teoh wrote: x = y; ^ ^ | | lvalue rvalue ... // This is OK: x = y + 1; // This is not OK: (y + 1) = x; Thanks for the clear explanation. My problem with the

Re: Proper way to handle "alias this" deprecation for classes

2023-05-10 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 10 May 2023 at 14:42:50 UTC, Inkrementator wrote: On Sunday, 7 May 2023 at 21:12:22 UTC, Chris Piker wrote: https://gist.github.com/run-dlang/9b7aec72710b1108fc8277789776962a Thanks for posting that. Reading over the code I'm reminded that I never cared whether something was

Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 7 May 2023 at 21:04:05 UTC, Inkrementator wrote: On Sunday, 7 May 2023 at 18:19:04 UTC, Ali Çehreli wrote: alias this is for implicit type conversions, which can be achieved explicitly as well. Open question to everybody: What you're opinion on using opCast for this? Since it's a

Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 7 May 2023 at 18:19:04 UTC, Ali Çehreli wrote: auto main() { auto c = new C(); // The same type conversion is now explicit: foo(c.asIntPtr); } Hi Ali Ah, very clear explanation, thanks! So basically to fix the problem I just delete the alias this line from dpq2, see

Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Chris Piker via Digitalmars-d-learn
Hi D One of the dependencies for my project has a class that makes use of the `alias x this` construct. According to dmd 2.103, alias this is deprecated for classes, so I'd like to correct the problem. Is there a specific paragraph or two that I can read to find out what is the

Re: Use dub to create source lib and executables

2023-03-04 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 4 March 2023 at 21:31:09 UTC, Richard (Rikki) Andrew Cattermole wrote: Yes dub was setup to cover the most common cases, but ignores when you have multiple outputs. Not ideal. There is a PR to add build steps currently, which will help improve things, so there is work to make dub

Re: Use dub to create source lib and executables

2023-03-04 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 4 March 2023 at 20:23:29 UTC, Steven Schveighoffer wrote: On 3/4/23 1:33 PM, Chris Piker wrote: If you mean that you have multiple subprojects inside your main dub project, my advice is to follow what other such projects do. I always look at vibe for my example. I have been

Re: Using Windbg to debug D applications and unittests

2023-03-04 Thread Chris Piker via Digitalmars-d-learn
On Monday, 27 February 2023 at 12:09:50 UTC, Basile B. wrote: At least this is what is done for the Dexed GDB widget, so that gdb breaks automatically when an Error or an Exception is new'd (https://gitlab.com/basile.b/dexed/-/blob/master/src/u_gdb.pas#L2072). Glad you mentioned Dexed. I Had

Use dub to create source lib and executables

2023-03-04 Thread Chris Piker via Digitalmars-d-learn
Hi D I normally work in a *nix environment, typically on server-side code. For many projects I have gnu makefiles that build a small lib along with command line utilities. Up to now I've been creating a dub.json file for just the sourceLibrary, and then putting embedded dub comments at the

Re: Deciding one member of iteration chain at runtime

2023-02-17 Thread Chris Piker via Digitalmars-d-learn
On Friday, 17 February 2023 at 17:42:19 UTC, Ali Çehreli wrote: // Two different steps auto g1 = r.map!((int n) => n * n); auto g2 = r.map!((int n) => n * 10); // The rest of the algoritm auto result = choose(condition, g1, g2) .array; Now that's a handy

Re: Deciding one member of iteration chain at runtime

2023-02-17 Thread Chris Piker via Digitalmars-d-learn
On Friday, 17 February 2023 at 17:44:20 UTC, H. S. Teoh wrote: Here's an actual function taken from my own code, that returns a different range type depending on a runtime condition, maybe this will help you? Thanks, this was helpful. I keep forgetting to expand my horizons on what can be

Deciding one member of iteration chain at runtime

2023-02-17 Thread Chris Piker via Digitalmars-d-learn
Hi D I have a main "loop" for a data processing program that looks much as follows: ```d sourceRange .operatorA .operatorB .operatorC .operatorD .operatorE .operatorF .operatorG .operatorH .copy(destination); ``` Where all `operator` items above are InputRange structs that

Re: Is there such a JSON parser?

2023-01-02 Thread Chris Piker via Digitalmars-d-learn
On Monday, 2 January 2023 at 14:56:27 UTC, SealabJaster wrote: Are you asking for a SAX-styled parser for JSON? I have an upcoming project (about 3-6 months away) that could make use of this as well. If you need someone to try it out please let me know and I'll give it a spin. Good luck

Re: importC and cmake

2022-09-29 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 28 September 2022 at 06:04:36 UTC, zjh wrote: On Wednesday, 28 September 2022 at 05:29:41 UTC, Chris Piker wrote: `Xmake` is indeed simpler. `Xmake` is really nice! zjh Sorry to go off topic for a moment, but do you happen to know how to tell xmake that my project is C

Re: importC and cmake

2022-09-27 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 00:31:53 UTC, zjh wrote: `xmake` is simpler. Thanks for the recommendation. Was struggling with cmake for a dependent clib. Xmake is indeed simpler.

Re: What are (were) the most difficult parts of D?

2022-05-22 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 22 May 2022 at 20:11:12 UTC, rikki cattermole wrote: On 23/05/2022 8:05 AM, Chris Piker wrote: Vibe.d is well tested against the frontend. Its part of dmd's test suite. See: https://buildkite.com/dlang/dmd/builds/26775 Thanks, that's handy.  Do you know where the equivalent test

Re: What are (were) the most difficult parts of D?

2022-05-22 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 22 May 2022 at 19:33:21 UTC, rikki cattermole wrote: I should probably jump back to another thread, but maybe one more reply isn't too much off topic discussion... DMD and LDC would have produced the same set of issues, because its the same frontend. Oh, the compile stage works

Re: What are (were) the most difficult parts of D?

2022-05-22 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 22 May 2022 at 19:01:41 UTC, rikki cattermole wrote: On 23/05/2022 6:06 AM, Chris Piker wrote: Iain's workload should be decreasing now that it is using the up to date frontend. Rather than the older C++ version with backports that he has been maintaining. Hats off to Iain for

Re: What are (were) the most difficult parts of D?

2022-05-22 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. To make it more meaningful, what is your experience with other languages? Ali Hi Ali, thanks for asking. Coming from C background I had problems

Re: Write UTF-8 bytes directly to stack buffer

2022-03-13 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 10 March 2022 at 17:59:33 UTC, H. S. Teoh wrote: Probably what you're looking for is std.format.formattedWrite. For example: ```d import std; void main() { ubyte[65536] buf; char[] usable_buf = cast(char[]) buf[]; usable_buf.formattedWrite!"Blah %d blah %s"(123,

Re: gdc or ldc for faster programs?

2022-03-10 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 20:04:04 UTC, Adam D Ruppe wrote: Not surprising at all: gdc is excellent and underrated in the community. The performance metrics are just a bonus. Gdc is the main reason I can get my worksite to take D seriously since we're a traditional unix shop (solaris

Write UTF-8 bytes directly to stack buffer

2022-03-10 Thread Chris Piker via Digitalmars-d-learn
Hi D There are quite a few string, array and range functions in phobos so I'm getting confused as to the right way to encode string data as UTF-8 directly into a stack buffer while keeping track of the write point. I have some output packets I'm building up in a tight loop. For speed I'm

Re: Source code for vibe.d listenTCP()

2022-03-08 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 27 February 2022 at 01:45:35 UTC, Adam D Ruppe wrote: My dpldocs.info search engine is not great right now but it can sometimes help find these things: http://search.dpldocs.info/?q=listenTCP Hi Adam Your site has been super helpful given the state of the vibe.d docs. It only

Re: Set output location for dub --single

2022-02-28 Thread Chris Piker via Digitalmars-d-learn
On Monday, 28 February 2022 at 08:03:24 UTC, Basile B. wrote: That 's not exactly what you ask for but you can define the path in the embedded recipe (targetPath) ```d #!/usr/bin/env dub /+ dub.sdl: dependency "mypackage" version="*" path=".." targetPath "./bin" +/ ``` Hey thanks!

Set output location for dub --single

2022-02-27 Thread Chris Piker via Digitalmars-d-learn
Hi D Coming from a python background it's worked well to organize my D projects as a dub `sourceLibrary` and then to put top level programs in a directory named `scripts` that are just dub single file projects. So the layout looks like this: ``` rootdir/ | +- mypackage/ || |

Simple way to handle rvalues and templates.

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
Hi D I have bit of code that was tripping me up. I need to parse small fields out of a big binary read, and it looks like some operations just can't be composed when it comes to using templates. So this works: ```d import std.bitmanip, std.system; ubyte[8192] data; ubyte[] temp =

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 27 February 2022 at 01:45:35 UTC, Adam D Ruppe wrote: and my website also offers a "see implementation" link at the bottom which has some inline code navigation jump links too to help. Yes! Freaking awesome! This needs to be a link on the regular D pages, or at least in the package

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 26 February 2022 at 22:25:46 UTC, Chris Piker wrote: Anyway if someone can just help me find the source code to listenTCP inside vibe.d I'd be grateful. Sorry to reply to myself, but I found the function. It was separated out into a separate package:

Source code for vibe.d listenTCP()

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm trying out the vibe.d framework for the first time and it looks like many of the functions mutate some hidden global state. Take for example `listenTCP`. To help me build a mental picuture of the framework I'd like to see what global state is mutated, but for the life of me I

Re: Tips on TCP socket to postgresql middleware

2022-02-22 Thread Chris Piker via Digitalmars-d-learn
On Monday, 21 February 2022 at 07:00:52 UTC, eugene wrote: On Monday, 21 February 2022 at 04:46:53 UTC, Chris Piker wrote: On Sunday, 20 February 2022 at 18:00:26 UTC, eugene wrote: I'm adverse to reading it closely since there was no license file and don't want to accidentally violate

Re: Tips on TCP socket to postgresql middleware

2022-02-20 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 20 February 2022 at 18:36:21 UTC, eugene wrote: I often use two connections, one for perform main task (upload some data and alike) and the second for getting notifications from PG, 'cause it very incovinient to do both in a single connection. Ah, a very handy tip. It would be

Re: Tips on TCP socket to postgresql middleware

2022-02-20 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 20 February 2022 at 18:00:26 UTC, eugene wrote: Yes, here is my engine with example (echo client/server pair): - [In D (for Linux & FreeBSD)](http://zed.karelia.ru/0/e/edsm-2022-02-20.tar.gz) The code is terse and clean, thanks for sharing :) I'm adverse to reading it closely

Re: Tips on TCP socket to postgresql middleware

2022-02-20 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 20 February 2022 at 17:58:41 UTC, Ali Çehreli wrote: Another one is to set the message box sizes to throttle. Message sizes and rates are relatively well know so it will be easy to pick a throttle point that's unlikely to backup the source yet provide for some quick DB maintenance

Re: Tips on TCP socket to postgresql middleware

2022-02-20 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 20 February 2022 at 15:20:17 UTC, eugene wrote: Most people will probably say this is crazy, but as to PG, one can do without libraries. I am doing so during years (in C, not D) and did not expierienced extremely complex troubles. I mean I do not use libpq - instead I implement some

Tips on TCP socket to postgresql middleware

2022-02-19 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm about to start a small program to whose job is: 1. Connect to a server over a TCP socket 2. Read a packetized real-time data stream 3. Update/insert to a postgresql database as data arrive. In general it should buffer data in RAM to avoid exerting back pressure on the input socket

Re: UFC creating name conflict

2021-10-09 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 9 October 2021 at 21:37:27 UTC, Paul Backus wrote: On Saturday, 9 October 2021 at 21:26:52 UTC, Chris Piker wrote: A struct member always takes priority over a UFCS function, so there must be something else going on that you've left out of your explanation. Can you post a

UFC creating name conflict

2021-10-09 Thread Chris Piker via Digitalmars-d-learn
Hi D I have and old C structure that I have to wrap that has a member named '.seconds', and in the module that handles this I also have conversion functions to go from an internal time representation to struct SysTime values. Unfortunately importing `core.time` brings in a seconds function,

Re: Using D "rocket" logo in outside presentation

2021-10-01 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 29 September 2021 at 05:44:59 UTC, Mike Parker wrote: On Wednesday, 29 September 2021 at 04:24:13 UTC, Chris Piker wrote: I'm to give a presentation to a combined NASA/ESA group in a few hours and would like to include a copy of the D "rocket" logo when mentioning new server side

Using D "rocket" logo in outside presentation

2021-09-28 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm to give a presentation to a combined NASA/ESA group in a few hours and would like to include a copy of the D "rocket" logo when mentioning new server side tools that I've written in D. Is such use of this particular [D

Recommendations on parsing XML via an InputRange

2021-09-13 Thread Chris Piker via Digitalmars-d-learn
Hi D I just finished a ~1K line project using `dxml` as the XML reader for my data streams. It works well in my test examples using memory mapped files, but like an impulse shopper I didn't notice that dxml requires `ForwardRange` objects. That's unfortunate, because my next enhancement

Re: Is std.variant useful for types only known at run time?

2021-09-08 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 8 September 2021 at 08:39:53 UTC, jfondren wrote: so I'd look at a std.sumtype of them first: Wow, this forum is like a CS department with infinite office hours! Interesting. I presume that the big win for using std.sumtype over a class set is value semantics instead of

Is std.variant useful for types only known at run time?

2021-09-08 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm working on data streaming reading module where the encoding of each input array isn't known until runtime. For example date-time column values may be encoded as: * An ISO-8601 UTC time string (aka char[]) * A ASCII floating point value with an indicated unit size and epoch

Re: Looking to get typeof parseXML return value

2021-09-06 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 7 September 2021 at 04:40:25 UTC, jfondren wrote: typeof(parseXML!simpleXML("")) xml; Hey, I like this trick! I was wondering what to use for the const(char)[] variable in the typeof statement. It's blindingly obvious in retrospect. Wouldn't work so well if there wasn't a

Re: Looking to get typeof parseXML return value

2021-09-06 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 7 September 2021 at 04:13:08 UTC, Chris Piker wrote: Any ideas on how to get the return type of `parseXML` below: ``` import dxml.parser; const(char)[] _mmfile; //_mmfile initialization TYPE??? _entityRng = parseXML!(simpleXML)(_mmfile); ``` Though it's ususally bad form to

Looking to get typeof parseXML return value

2021-09-06 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm using the **dxml** library since I like it's "pull here for more data" mentality. I've come across the need to save an entity range created by the `parseXML` function as a class member so that I can tuck it away and pull more data as needed. Like almost all new users to D I'm

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-30 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 27 May 2021 at 07:00:32 UTC, Imperatorn wrote: I would like to recommend DlangUI [1], but we have tried now for months to get in contact with the owner of it (to take over development) and are getting no reponse. 1. https://github.com/buggins/dlangui Of the 107 forks of dlangui

State of D for webassembly

2021-05-17 Thread Chris Piker via Digitalmars-d-learn
Hi D Our group has some spectragram (aka dynamic spectra) creation algorithms that are fast in Java and since D has many Java-ish concepts it looks like it would be do-able to port the code to D. If I take on this project my target would be to run as a webassembly program. What is the

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Monday, 17 May 2021 at 00:27:01 UTC, SealabJaster wrote: On Sunday, 16 May 2021 at 23:52:06 UTC, Adam D. Ruppe wrote: ... I've opened a PR (https://github.com/dlang/dmd/pull/12526) with a super hacked together proof-of-concept. As I say in the PR I don't know if I'm actually capable of

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 13:35:02 UTC, Adam D. Ruppe wrote: Wait, what's the bug there? The typeof DOES tell you they are separate. Error: cannot implicitly convert expression `b` of type `S!(func2)` to `S!(func1)` Sorry, it's a forum post, so I really should have been more explicit. It

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 10:10:54 UTC, SealabJaster wrote: It's due to a quirk with passing lambdas as template arguments. Each lambda is actually separated into its own function. Hey that was a very well laid out example. Okay, I think the light is starting do dawn. So if I use lambdas

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:17:47 UTC, Jordan Wilson wrote: Another example: ```d auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a => a.to!int)]; # compile error ``` Hi Jordan Nice succinct example. Thanks for looking at the code :) So, honest question. Does it strike you as

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 14:05:34 UTC, Paul Backus wrote: If you post your code (or at least a self-contained subset of it) someone can probably help you figure out where you're running into trouble. The error messages by themselves do not provide enough information--all I can say from

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
Thanks to everyone who has replied. You've given me a lot to think about, and since I'm not yet fluent in D it will take a bit to digest it all, though one thing is clear. This community is one of the strong features of D. I will mention it to others as a selling point. Best,

Re: Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 14:05:34 UTC, Paul Backus wrote: If you post your code (or at least a self-contained subset of it) someone can probably help you figure out where you're running into trouble. Smart idea. It's all on github. I'll fix a few items and send a link soon as I get a

Re: Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 13:43:29 UTC, Mike Parker wrote: On Saturday, 15 May 2021 at 11:25:10 UTC, Chris Piker wrote: In addition to what Adam said, if you do need to store the result for use in a friendlier form, just import `std.array` and append `.array` to the end of the pipeline.

Re: Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:51:11 UTC, Adam D. Ruppe wrote: On Saturday, 15 May 2021 at 11:25:10 UTC, Chris Piker wrote: The idea is you aren't supposed to care what the type is, just what attributes it has, e.g., can be indexed, or can be assigned, etc. (Warning, new user rant ahead.

Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Chris Piker via Digitalmars-d-learn
Hi D Since the example of piping the output of one range to another looked pretty cool, I've tried my own hand at it for my current program, and the results have been... sub optimal. Basically the issue is that if one attempts to make a range based pipeline aka: ```d auto mega_range =

Re: Any suggestions on dmd error message formatting?

2021-05-15 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 06:12:25 UTC, SealabJaster wrote: On Saturday, 15 May 2021 at 04:54:15 UTC, Chris Piker wrote: T_T My eyes burn. Good, it's not just me. If figured the Deities out there visually parse these messages even hung over. Seems the final `int function` parameter

Any suggestions on dmd error message formatting?

2021-05-14 Thread Chris Piker via Digitalmars-d-learn
Hi D So the compile error messages getting from dmd are starting to remind me of the notorious 130 line error message I once got from a C++ compiler for missing a comma in a template. :-/ (After fixing that bug, I left work early and came back the next day with a python book.) So, like

Re: Testing for object property supporting "<" comparison

2021-05-11 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 00:06:52 UTC, Paul Backus wrote: On Tuesday, 11 May 2021 at 19:42:34 UTC, Chris Piker wrote: std.traits.isOrderingComparable https://phobos.dpldocs.info/std.traits.isOrderingComparable.html Well I feel sheepish, don't know how I missed that one. Hey thanks for

Testing for object property supporting "<" comparison

2021-05-11 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm working on a bit of code that handles selecting one *.front from multiple range-ish objects. It's a select-or-drop algorithm for a data streaming service, the details aren't important. The algorithm takes a range of something I'll call "PriorityRange" objects. PriorityRange

Re: Selected elements from splitter output

2021-05-04 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 4 May 2021 at 22:02:11 UTC, Ali Çehreli wrote: On 5/4/21 1:40 PM, Chris Piker wrote: > I only care about columns 0, 2, 3, 4, 8, 9, 10. That's std.range.stride. > char[][] wanted = string_range.get( [1, 5, 7] ); // pseudo-code element That's std.range.indexed. Hey Thanks! And

Selected elements from splitter output

2021-05-04 Thread Chris Piker via Digitalmars-d-learn
Hi D I have a white-space delimited file with quite a few columns, but I only care about columns 0, 2, 3, 4, 8, 9, 10. Since I don't need most of the 60+ columns it seemed like: std.algorithm.iteration.splitter() would be a better function to use then std.array.split(). My problem is

Re: Need for speed

2021-04-01 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 1 April 2021 at 16:52:17 UTC, Nestor wrote: I was hoping to beat my dear Python and get similar results to Go, but that is not the case neither using rdmd nor running the executable generated by dmd. I am getting values between 350-380 ms, and 81ms in Python. Nice test. I'm new

Re: Creating a .di file for a custom C library

2021-03-30 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 30 March 2021 at 04:01:12 UTC, Brad wrote: 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

Re: Contributing CDF bindings to Deimos

2021-03-25 Thread Chris Piker via Digitalmars-d-learn
On Friday, 26 March 2021 at 00:50:36 UTC, Jordan Wilson wrote: Nice one. I've used HDF5/NetCDF, will have to check out and see what CDF offers. AFAIK CDF is much simpler than NetCDF. If you do generate CDF files and want other common tools to understand your data structures, use the ISTP

Re: Contributing CDF bindings to Deimos

2021-03-25 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 25 March 2021 at 16:57:05 UTC, Bastiaan Veelo wrote: On Thursday, 25 March 2021 at 04:00:33 UTC, Chris Piker wrote: As an aside, software developers at NASA Goddard have now heard of D which is nice. They were pleased to see that it was supported by gcc. (Hat tip to the GDC team)

Re: Contributing CDF bindings to Deimos

2021-03-24 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 23 March 2021 at 05:54:13 UTC, mw wrote: On Tuesday, 23 March 2021 at 05:34:57 UTC, Chris Piker wrote: Create a github repo, and create an account on: https://code.dlang.org/ Then you can register your project there, and supported by dub build. Okay, that's done. The repo

Contributing CDF bindings to Deimos

2021-03-22 Thread Chris Piker via Digitalmars-d-learn
Hi D There is a C library that's important for my line of work, https://cdf.gsfc.nasa.gov/ but it's not exactly a popular library in the general sense. I willing to contribute & maintain D bindings for this library following the Deimos guidelines but am wondering if it's too specific to

Re: noobie question, dub or meson?

2021-03-22 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 20 March 2021 at 18:33:20 UTC, James Blachly wrote: Chris: for one of my (D) libraries that also links in an .o file that's built from C source, I have a makefile for the C and call `make` during the dub build process. It is not incredibly sophisticated, but works well for us.

Re: noobie question, dub or meson?

2021-03-19 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 18 March 2021 at 06:02:03 UTC, Elronnd wrote: Meson doesn't track dependencies properly for d, so your dirty builds will be wrong if you go that route. You might consider keeping the c and d code in the same repository, but with separate build systems; using dub to build the d

noobie question, dub or meson?

2021-03-17 Thread Chris Piker via Digitalmars-d-learn
Hi D I've started a D layer for one of my C libraries that's adds some new functionality and a bit of an interface upgrade. In turn I'm using this combined code-base as a dependency for D "scripts". Since my software is used by a few outside groups in my field, it seems I should get used

Re: rdmd and D equivalent for PYTHONPATH?

2021-03-17 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 20:24:19 UTC, Tobias Pankrath wrote: For scripts this could be a good way, but it does not really work with most dub packages: 1. put all your dependencies into a single location, like /home//dstuff 2. add -I /home//dstuff to your call to rdmd/dmd (or put

Re: rdmd and D equivalent for PYTHONPATH?

2021-03-17 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 20:13:49 UTC, Imperatorn wrote: On Wednesday, 17 March 2021 at 19:33:26 UTC, Chris Piker wrote: On Wednesday, 17 March 2021 at 09:34:21 UTC, Mike Parker wrote: [...] Sure will, thanks for the invite to contribute in a specific way. [...] You probably

Re: rdmd and D equivalent for PYTHONPATH?

2021-03-17 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 09:34:21 UTC, Mike Parker wrote: On Wednesday, 17 March 2021 at 07:13:31 UTC, Chris Piker wrote: Very handy example. Unfortunately it means that paths are embedded in scripts, which is usually a bad idea. The ability to use D source modules “script style” is

Re: rdmd and D equivalent for PYTHONPATH?

2021-03-17 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 06:07:01 UTC, user1234 wrote: You can use local a specific local version too, for example the git repository #!/usr/bin/env dub /+ dub.sdl: dependency "mir-algorithm" path="/home/x/repositories/mir/mir-algorithm" +/ In addition with --nodeps, no

Re: rdmd and D equivalent for PYTHONPATH?

2021-03-16 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 03:43:22 UTC, Chris Piker wrote: Note: I'm aware of dub. This isn't a question about dub. I'm making scripts for local use, not redistributable binaries, so I would like to "install" mir-algorithm and similar libraries for my rdmd scripts to use. Sorry to

rdmd and D equivalent for PYTHONPATH?

2021-03-16 Thread Chris Piker via Digitalmars-d-learn
Hi D I've writing little test scripts using rdmd to understand what various functions are really doing (ex: .take(5)). I'm up to the point where I need to write sample code to understand mir-algorithm a little better, but of course the library is not installed on my system. So two related

  1   2   >