Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 19 January 2023 at 04:22:21 UTC, thebluepandabear wrote: ... I also wrote this article[1] recently exploring how one of my D libraries make use of templates and metaprogramming. Unfortuantely the LinkedIn editor is complete trash and I got to the point any change at all would

Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 19 January 2023 at 04:22:21 UTC, thebluepandabear wrote: ... I presented a talk[1] at Dconf online 2021, which may or may not be what you're looking for. I know my mic audio is pretty bad, but honestly the slides themselves have all the information you need, so you can just

Re: Is there such a JSON parser?

2023-01-02 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 1 January 2023 at 23:28:12 UTC, torhu wrote: I need to parse some JSON data into various data structures, so I'm looking for a parser based on events or ranges. One that doesn't just load the file and build a data structure that represents the whole thing. So not std.json, at least.

Re: Why do we have Dmain?

2021-10-25 Thread SealabJaster via Digitalmars-d-learn
On Monday, 25 October 2021 at 07:49:44 UTC, user1234 wrote: in addition to the other answers, there's also the parameters of main: Also, all programs running under the D runtime have special command line arguments(`--DRT` arguments). The Runtime needs to be able to parse those arguments at

Re: better c fibers

2021-09-26 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 26 September 2021 at 09:48:58 UTC, SealabJaster wrote: ... I feel I didn't make it clear enough that extracting the code would be way too much effort than its worth, especially since I'm not even sure it runs on Linux. So I really wouldn't suggest going down that route.

Re: better c fibers

2021-09-26 Thread SealabJaster via Digitalmars-d-learn
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote: ... I'm not aware of any -betterC package specifically for coroutines. I have some work done in this regard, but sadly the library itself isn't really usable at all so if you want to put in the effort you'd have to probably extract

Re: Bitfield woes

2021-08-16 Thread SealabJaster via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:47:54 UTC, SealabJaster wrote: ... Wait, I'm actually just a moron. I should be using `uint` and not `int`

Bitfield woes

2021-08-16 Thread SealabJaster via Digitalmars-d-learn
I swear I'm not being stupid right: https://run.dlang.io/is/Wfd214 I should be seeing: ``` 7 // 111 7 // 111 3 // 11 [no error message] ``` instead of: ``` 3 // 11 3 // 11 1 // 1 core.exception.AssertError@onlineapp.d-mixin-8(9): Value is greater than the maximum value of bitfield 'a' ```

Re: Tracy

2021-08-07 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 7 August 2021 at 14:36:39 UTC, Dennis wrote: I'm not aware of any documentation of the feature. Could this be fixed? Or is this intentional?

Re: Relocation error

2021-08-04 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 4 August 2021 at 20:24:28 UTC, SealabJaster wrote: .. Oops, please ignore, put it into lflags instead of dflags

Re: Relocation error

2021-08-04 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 4 August 2021 at 19:47:42 UTC, Paul Backus wrote: ... I am now getting this error: ``` /usr/bin/ld: -f may not be used without -shared ``` Adding -shared: ``` /usr/bin/ld: .dub/build/test-debug-linux.posix-x86_64-dmd_v2.097.1-3DC2262935789AAE4203853EDDD1C5A4/libd.o:

Re: Relocation error

2021-08-04 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 4 August 2021 at 18:52:40 UTC, SealabJaster wrote: ... Forgot to mention: Build with `dub run --compiler=dmd -c test`

Relocation error

2021-08-04 Thread SealabJaster via Digitalmars-d-learn
I'm currently working on a libc-less standard library for myself, and was working on Posix support recently. However, I'm now running into the following linker error that I really don't know what to do with: ``` /usr/bin/ld:

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 03:51:02 UTC, SealabJaster wrote: ... There's also Ali Cehreli's book, which is excellent. e.g. here's the section on UDAs: http://ddili.org/ders/d.en/uda.html

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 01:56:21 UTC, someone wrote: ... Prepare yourself, as you may become a metaprogramming junkie in the near future. Throw in `static if`[0] `static foreach`[1] `string mixin()`[2] `CTFE`[3] and make some crazy, random, arcane mess of fun spaghetti. I've wrote

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 03:05:24 UTC, Paul Backus wrote: ... Yea, that's true.

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 01:26:25 UTC, someone wrote: ... Not 100% sure this works in all cases, but this version doesn't need the caller to make use of a mixin: https://run.dlang.io/is/3jLxLz

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 05:59:19 UTC, SealabJaster wrote: I've ran into this rarely. At a guess, it seems something triggers the compiler to either evaluate something in non-lexical order; doesn't realise it needs to error out at the static assert instead of doing it later, or maybe it

Re: static assert not printing out along the error diagnostic

2021-07-14 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 03:06:06 UTC, someone wrote: ... I've ran into this rarely. At a guess, it seems something triggers the compiler to either evaluate something in non-lexical order; doesn't realise it needs to error out at the static assert instead of doing it later, or maybe it

Re: How to execute a random postgresql-query.

2021-06-29 Thread SealabJaster via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 18:25:52 UTC, someone wrote: Can you elaborate why you went your own way coding your own bindings to pglib instead of using the existing ones ? Not who you were asking but: they just don't work. Maybe they don't support Windows for one reason or another. Maybe

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
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 pushing it forward if the idea gets accepted, but I've

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 16 May 2021 at 20:32:08 UTC, SealabJaster wrote: ... You could even make a helper function that lets the compiler infer the lambda's type for you: ```d struct S(T) { alias FT = T function(T); FT func; } S!T s(T)(T function(T) func) { return S!T(func); } void main() {

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 16 May 2021 at 12:54:19 UTC, Chris Piker wrote: ... If all you need is a single type for the parameter(s) and return type, then it can be simplified a bit to save you some typing: ```d struct S(T) { alias FT = T function(T); FT func; } void main() { auto a = S!int(a =>

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:55:31 UTC, Chris Piker wrote: Maybe that's eminently reasonable to those with deep knowledge, but it seems crazy to a new D programmer. It breaks a general assumption about programming when copying and pasting a definition yields two things that aren't the same

Re: Any suggestions on dmd error message formatting?

2021-05-15 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 15 May 2021 at 09:09:36 UTC, Berni44 wrote: ... Honestly, even having a dumb formatter that puts things like this would be 100x more useable than what we currently get: ```d das2.range.PriorityRange!( DasRange!( Take!( ZipShortest!( cast(Flag)false, Result,

Re: Any suggestions on dmd error message formatting?

2021-05-15 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 15 May 2021 at 08:15:19 UTC, Chris Piker wrote: I did much the same as you and reformatted the error message to find the bug. As to the larger question of how to automatically process compiler output... got any ideas? Hope someone who knows how to modify DMD bothers to: 1.

Re: Any suggestions on dmd error message formatting?

2021-05-15 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 15 May 2021 at 06:12:25 UTC, SealabJaster wrote: ... Honestly I also kind of wish that the D compilers could format functions better on the command line, because these giant blobs of "where's ~~wally~~ the difference?" are just horrid when they show up.

Re: Any suggestions on dmd error message formatting?

2021-05-15 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 15 May 2021 at 04:54:15 UTC, Chris Piker wrote: Hi D T_T My eyes burn. Anyway, Here it is formatted slightly better: ```d PriorityRange.this( DasRange!( Tuple!(int, int)[], int function(Tuple!(int, int)) pure nothrow @nogc @safe,

Re: Cannot access frame pointer of a struct with member function

2021-05-09 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 9 May 2021 at 17:37:40 UTC, Andrey Zherikov wrote: ... https://run.dlang.io/is/sCUdXe shows this a bit more clearly.

Re: Cannot access frame pointer of a struct with member function

2021-05-09 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 9 May 2021 at 17:37:40 UTC, Andrey Zherikov wrote: Is this a bug? My best guess is that, since the struct doesn't have any member functions the compiler has decided that the struct doesn't need any access to the main function's context/frame pointer, so the struct has implicitly

Re: Introspection of exceptions that a function can throw

2021-02-24 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 19:58:41 UTC, SealabJaster wrote: ... Just realised that can include duplicates, but there's std.meta.NoDuplicates to solve that.

Re: Introspection of exceptions that a function can throw

2021-02-24 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 19:38:53 UTC, Mark wrote: Is there a way to obtain a list, at compile-time, of all the exception types that a function might throw (directly or through a call to another function)? Thanks. I don't believe that there's any built-in way, as that'd mean that

Re: Weird interaction with public and non-public imports

2021-01-28 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 28 January 2021 at 13:13:46 UTC, Paul Backus wrote: ... https://issues.dlang.org/show_bug.cgi?id=21589 These issues are always so subtle and specific yet so annoying, e.g.: https://issues.dlang.org/show_bug.cgi?id=21496 and https://issues.dlang.org/show_bug.cgi?id=21377

Weird interaction with public and non-public imports

2021-01-28 Thread SealabJaster via Digitalmars-d-learn
Please see: https://run.dlang.io/is/2mwcPH I'd expect that the `isInstanceOf` would be true instead of false here. Commenting out the public import changes the output of `fullyQualifiedName`. I can kind of see why this happens, but it's kind of annoying when things like `isInstanceOf`

Re: Why filling AA in shared library freezes execution?

2021-01-27 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 16:38:07 UTC, Adam D. Ruppe wrote: ... Yikes! Ok, I thought DLLs were just "sort of" unusable due to the RTTI issue, but now I'm convinced that they're almost completely useless in their current state unless you want to live in a world of hurt and pain.

Re: Why filling AA in shared library freezes execution?

2021-01-27 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 13:39:32 UTC, SealabJaster wrote: I've crossed them out of my mind entirely at this point though, since Windows in general doesn't seem to get much love in certain parts of D (e.g. the makefile for Phobos didn't support things that the posix makefile did).

Re: Why filling AA in shared library freezes execution?

2021-01-27 Thread SealabJaster via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 17:39:50 UTC, H. S. Teoh wrote: On Tue, Jan 26, 2021 at 02:12:17PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: On Monday, 25 January 2021 at 21:48:10 UTC, Vitalii wrote: > Q: Why filling assoc.array in shared library freeze > execution? D exes loading D

Re: Static constructor

2021-01-14 Thread SealabJaster via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 11:28:12 UTC, ludo wrote: Ok, I agree that ends up being a kind of strange singleton. But yes it was D v1 code. Do we agree that the following multi-threaded singleton pattern is the proper way as of today. It looks fine to me. The D wiki has the following

Re: Static constructor

2021-01-06 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 7 January 2021 at 01:55:07 UTC, SealabJaster wrote: ... And on a side note, I don't believe this code is working as the author intends. Someone correct me if I'm wrong, but `static` variables in D arethread-local, so a `static Object mutex` wouldn't actually be visible

Re: Static constructor

2021-01-06 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 6 January 2021 at 17:05:02 UTC, ludo wrote: ... Using a static class like this seems to mostly be a design decision. i.e. instead of using something like ``` openalGetMutex(); // OR OpenAL openal = ...; openal.getMutex(); // OR I guess even this g_openal.getMutex(); ```

Re: C++ or D?

2021-01-01 Thread SealabJaster via Digitalmars-d-learn
On Friday, 1 January 2021 at 16:45:16 UTC, Ola Fosheim Grøstad wrote: I don't know anything about any official positions other than the fact that Walter dislikes having more than one pointer type and is working on some kind of "liveness" verification for a C-style free/malloc regime, which is

Re: C++ or D?

2021-01-01 Thread SealabJaster via Digitalmars-d-learn
On Friday, 1 January 2021 at 15:12:43 UTC, Ola Fosheim Grøstad wrote: On Friday, 1 January 2021 at 15:01:15 UTC, RSY wrote: one big move would be to finally put the allocators out of std.experimental, and finally embrace this everywhere (just like ziglang) I am bit torn on this, the less the

Re: Alias woes

2020-12-20 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 19 December 2020 at 07:41:09 UTC, SealabJaster wrote: ... The nesting behavior is indeed intentional: https://dlang.org/spec/template.html#implicit-nesting But I still assume the assignment to a function is also a bug, so I'll file that if it hasn't been already (unless for

Re: Alias woes

2020-12-18 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 17 December 2020 at 22:06:00 UTC, SealabJaster wrote: ... Well, at least I understand why the context pointer exists now. If you were to add a `pragma(msg, __FUNCTION__)` into either of the templated functions, you'd get the following output. ``` example.C.doShizz!(a).doShizz

Re: Alias woes

2020-12-17 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 17 December 2020 at 21:10:20 UTC, Q. Schroll wrote: I don't have an answer, but aliasing non-static fields outside the struct isn't something one does often. This is probably a bug. At least it wasn't just me overlooking something. If it is a bug, I wonder which part of it is

Alias woes

2020-12-11 Thread SealabJaster via Digitalmars-d-learn
Please see this shortened snippet: https://godbolt.org/z/j8f3x5 I've ran into annoyances before when using aliases to member fields, but something subtle like this was rather annoying to figure out. Why does the compiler feel the need to embed a context pointer anytime you provide an to

Re: question as to when a new command gets executed

2020-11-11 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 11 November 2020 at 22:10:38 UTC, WhatMeWorry wrote: Thanks. Would you or anyone reading this know if this is unique to D or does C++ also behave like this? Also, where is the memory, that new allocates? Is it in the heap (thought heap was available only at runtime) or some

Re: Unclear error message

2020-11-10 Thread SealabJaster via Digitalmars-d-learn
On Wednesday, 11 November 2020 at 02:05:33 UTC, H. S. Teoh wrote: Definitely. Bad/confusing error messages should always be improved. Please file a bug at: http://issues.dlang.org/ T https://issues.dlang.org/show_bug.cgi?id=21377 I wonder if this is the same as:

Unclear error message

2020-11-10 Thread SealabJaster via Digitalmars-d-learn
Please see the code at https://run.dlang.io/is/Yjidek As I understand the error is caused by trying to provide a delegate when there's no context to provide. Not complaining about that. However what I am complaining about is about the error message: `onlineapp.d(31): Error: delegate

Re: Should the compiler be failing to infer template args here?

2020-06-19 Thread SealabJaster via Digitalmars-d-learn
On Friday, 19 June 2020 at 16:31:50 UTC, Paul Backus wrote: This is a known issue: https://issues.dlang.org/show_bug.cgi?id=1807 "Reported: 2008"... yikes. Thanks anyway, glad to know I wasn't just going mad :)

Should the compiler be failing to infer template args here?

2020-06-19 Thread SealabJaster via Digitalmars-d-learn
If you take a look at this code here: https://godbolt.org/z/4T3uLh You can see that when using a templated alias, the compiler fails to infer the T template parameter, but only when using the function that also asks for the alias, instead of the original type. I was just wondering if this

Re: Does D have class' attributes like C#'s?

2017-12-17 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: Does D have something similar? As others have said, D has UDAs. An alternative to using __traits(getAttributes) is to use std.traits.getUDAs [1] I've made a small example using std.traits.getUDAs, based off of your example. [2]