digitalmars.D - Asking for advice - assert for ImportC
- Walter Bright (5/5) Apr 27 2022 I put in a PR to add __assert(assign-expression) to ImportC, for reasons...
- rikki cattermole (2/2) Apr 27 2022 Do we really need to be introducing our own unique extensions for C that...
- Walter Bright (3/5) Apr 28 2022 No, we don't have to do this. But it makes the ImportC test suite a lot ...
- Dennis (7/9) Apr 28 2022 If it's about test suite convenience, you don't need a new
- Salih Dincer (5/11) Apr 28 2022 Although I don't understand it technically (what are DI files?),
- rikki cattermole (3/4) Apr 28 2022 .di files are like regular .d files except by convention non-templated
- Loara (4/9) Apr 29 2022 How I can prevent a function body from being removed in an
- =?UTF-8?Q?Ali_=c3=87ehreli?= (10/13) Apr 29 2022 Other than templates, the compiler needs the bodies of 'auto' functions
- Guillaume Piolat (2/7) Apr 29 2022 When are they needed?
- Mike Parker (3/7) Apr 29 2022 I think the primary use case would be if you want to distribute a
- Adam D Ruppe (14/15) Apr 29 2022 They are never needed, per se, but they have some potential in
- Dennis (2/4) Apr 29 2022 Why not?
- Adam D Ruppe (44/45) Apr 29 2022 Long list:
- rikki cattermole (5/14) Apr 29 2022 I will be using them for my shared libraries.
- Mike Parker (2/3) Apr 28 2022 https://dlang.org/dmd-linux.html#interface_files
- Daniel N (3/8) Apr 27 2022 _D_assert
- Era Scarecrow (5/16) Jul 16 2022 asserting, asserted, checking, checked, determine, guaranteed,
- Salih Dincer (6/12) Apr 28 2022 **2.**
- Salih Dincer (11/22) Jul 09 2022 I want to make a new suggestion to you; if the English meaning is
- duser (7/12) Apr 28 2022 maybe `_Assert`? similar to `_Static_assert`
- Walter Bright (4/10) Apr 29 2022 I like __importc_assert, except it's a bit long.
- zjh (2/4) Apr 29 2022 __cassert().
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/12) Apr 29 2022 Thesaurus is my friend: "affirm" looks better than
I put in a PR to add __assert(assign-expression) to ImportC, for reasons explained in the PR: https://github.com/dlang/dmd/pull/14026 Unfortunately, some C compilers use __assert. Arghh! I seem unable to come up with a decent name. Advice welcome!
Apr 27 2022
Do we really need to be introducing our own unique extensions for C that can introduce new conflicts later on?
Apr 27 2022
On 4/27/2022 9:36 PM, rikki cattermole wrote:Do we really need to be introducing our own unique extensions for C that can introduce new conflicts later on?No, we don't have to do this. But it makes the ImportC test suite a lot more convenient.
Apr 28 2022
On Thursday, 28 April 2022 at 08:05:22 UTC, Walter Bright wrote:No, we don't have to do this. But it makes the ImportC test suite a lot more convenient.If it's about test suite convenience, you don't need a new language feature. You can define your own assert template and import it in tests that need it. If manually importing it is too inconvenient as well, you can modify the test suite runner to add the import statement, or add it to [__builtins.di](https://github.com/dlang/druntime/blob/maste /src/__builtins.di) under a version condition that's set in the test suite.
Apr 28 2022
On Thursday, 28 April 2022 at 08:29:41 UTC, Dennis wrote:On Thursday, 28 April 2022 at 08:05:22 UTC, Walter Bright wrote:Although I don't understand it technically (what are DI files?), I support Dennis's opinion but I care about ImportC... And please do whatever is necessary to make it easier. SDB 79No, we don't have to do this. But it makes the ImportC test suite a lot more convenient.[...] you can modify the test suite runner to add the import statement, or add it to [__builtins.di](https://github.com/dlang/druntime/blob/maste /src/__builtins.di) under a version condition that's set in the test suite.
Apr 28 2022
On 29/04/2022 2:24 PM, Salih Dincer wrote:Although I don't understand it technically (what are DI files?),.di files are like regular .d files except by convention non-templated functions have their bodies removed.
Apr 28 2022
On Friday, 29 April 2022 at 02:29:25 UTC, rikki cattermole wrote:On 29/04/2022 2:24 PM, Salih Dincer wrote:How I can prevent a function body from being removed in an interface file (because that function should be evaluated at compile time)?Although I don't understand it technically (what are DI files?),.di files are like regular .d files except by convention non-templated functions have their bodies removed.
Apr 29 2022
On 4/29/22 02:59, Loara wrote:How I can prevent a function body from being removed in an interface fileOther than templates, the compiler needs the bodies of 'auto' functions to determine what type they return: auto foo() { // ... }(because that function should be evaluated at compile time)?You simply use the .d file that includes the definitions during compilation. I always saw .di files as the .h equivalents of C, which are not needed in D but for distributing a library. (I don't think I will ever need them.) Ali
Apr 29 2022
On Friday, 29 April 2022 at 02:29:25 UTC, rikki cattermole wrote:On 29/04/2022 2:24 PM, Salih Dincer wrote:When are they needed?Although I don't understand it technically (what are DI files?),.di files are like regular .d files except by convention non-templated functions have their bodies removed.
Apr 29 2022
On Friday, 29 April 2022 at 13:15:10 UTC, Guillaume Piolat wrote:I think the primary use case would be if you want to distribute a closed-source library..di files are like regular .d files except by convention non-templated functions have their bodies removed.When are they needed?
Apr 29 2022
On Friday, 29 April 2022 at 13:15:10 UTC, Guillaume Piolat wrote:When are they needed?They are never needed, per se, but they have some potential in improving compile time by caching some results and hiding implementations. Especially combined with local imports, hiding the body can hide the entire import web, which can hide whole ctfe calculations. I also think we can set it to avoid template generations by doing them extern if it is already in the lib which can further help compile times if all goes well. The hard part is keeping it in sync. The compiler won't help you at all, aside from its -H generation, which isn't great. And if you forget to regenerate, you have possible ABI mismatch; the compiler won't check against an intended thing. (This is something I'd love to see a dub 2.0 tackle.)
Apr 29 2022
On Friday, 29 April 2022 at 14:34:16 UTC, Adam D Ruppe wrote:The compiler won't help you at all, aside from its -H generation, which isn't great.Why not?
Apr 29 2022
On Friday, 29 April 2022 at 15:10:28 UTC, Dennis wrote:Why not?Long list: * it is liable to outright break code, keeping a CTFE initializer while stripping the body. See: ushort listeningPort = defaultListeningPort(); cgi.di(1165): Error: `defaultListeningPort` cannot be interpreted at compile time, because it has no available source code Ideally, it would actually just evaluate it and spit out the answer instead of keeping the function there to be rerun each build. * it keeps unnecessary imports this would need to find unneeded imports and strip them, so new feature, but useful one * it keeps bodies of constructors unnecessarily this feels like it might just be a bug, since it removes other function bodies, but it might also have to do with a workaround for the uninitialized control flow logic * it keeps private data and members this means more imports must be kept which is a major compile time cost and limits encapsulation. keeping sizes and vtables syncing can be tricky, but replacing private data with private ubyte[N] blocks might work in some cases. postblits and such might complicate the issue. TLS might also complicate. * it doesn't expand mixins if something is mixed in locally with local arguments, might as well expand it here and prevent work. Another case of recognizing when CTFE can actually be cached or not; it depends on its parameters. * you can't tell it to strip static ifs and versions sometimes those checks are themselves a bit costly and again, some CTFE stripping opportunities. * it doesn't collapse unnecessary templates to reuse impls this is easier said than done so might need to be an external step though, but you can avoid creating new instances if it is already in the object file I think that's my big items. My view of the .di generation is it can be a direct companion to a .obj file - it describes what is needed to use the object file and caches other source things. So together they'd minimize work done. This isn't always what you want from it though, maybe you want reuse the same .di file from different builds but really if it is bundled with a .obj anyway - which is the case in a cached build and in a closed source distribution - I think there's a lot of potential in speeding things up.
Apr 29 2022
On 30/04/2022 1:15 AM, Guillaume Piolat wrote:On Friday, 29 April 2022 at 02:29:25 UTC, rikki cattermole wrote:I will be using them for my shared libraries. There are some expensive bits that I really don't want to be reparsed (nor does it need to be). Most people probably won't need to use them as others have said.On 29/04/2022 2:24 PM, Salih Dincer wrote:When are they needed?Although I don't understand it technically (what are DI files?),.di files are like regular .d files except by convention non-templated functions have their bodies removed.
Apr 29 2022
On Friday, 29 April 2022 at 02:24:12 UTC, Salih Dincer wrote:Although I don't understand it technically (what are DI files?),https://dlang.org/dmd-linux.html#interface_files
Apr 28 2022
On Thursday, 28 April 2022 at 04:33:18 UTC, Walter Bright wrote:I put in a PR to add __assert(assign-expression) to ImportC, for reasons explained in the PR: https://github.com/dlang/dmd/pull/14026 Unfortunately, some C compilers use __assert. Arghh! I seem unable to come up with a decent name. Advice welcome!_D_assert ___assert
Apr 27 2022
On Thursday, 28 April 2022 at 06:59:24 UTC, Daniel N wrote:On Thursday, 28 April 2022 at 04:33:18 UTC, Walter Bright wrote:asserting, asserted, checking, checked, determine, guaranteed, debugcheck, plankcheck, deathcheck, halt_if_fails, affirmation, affirm, polaris (north star), harden, oneway, yieldif, assertcorrect, notfalse, notnottrue, proof, proving, proved...I put in a PR to add __assert(assign-expression) to ImportC, for reasons explained in the PR: https://github.com/dlang/dmd/pull/14026 Unfortunately, some C compilers use __assert. Arghh! I seem unable to come up with a decent name. Advice welcome!_D_assert ___assert
Jul 16 2022
On Thursday, 28 April 2022 at 04:33:18 UTC, Walter Bright wrote:[...] Unfortunately, some C compilers use __assert. Arghh!**1.**`__assert__`**2.**`__assertion`**3.**`__assertor`**4.**`__asserted`SDB 79
Apr 28 2022
On Thursday, 28 April 2022 at 07:20:34 UTC, Salih Dincer wrote:On Thursday, 28 April 2022 at 04:33:18 UTC, Walter Bright wrote:I want to make a new suggestion to you; if the English meaning is not contradictory! "ascertain" that can't introduce new conflicts never? ```d assert(true); ascertain(true); ``` Sounds good, huh? Okay, it's 3 letters more but it is better than underscore typed by double key press.:) SDB 79[...] Unfortunately, some C compilers use __assert. Arghh!**1.**`__assert__`**2.**`__assertion`**3.**`__assertor`**4.**`__asserted`
Jul 09 2022
On Thursday, 28 April 2022 at 04:33:18 UTC, Walter Bright wrote:I put in a PR to add __assert(assign-expression) to ImportC, for reasons explained in the PR: https://github.com/dlang/dmd/pull/14026 Unfortunately, some C compilers use __assert. Arghh! I seem unable to come up with a decent name. Advice welcome!maybe `_Assert`? similar to `_Static_assert` it almost looks like something you could expect to see in a future C standard adding a prefix to the double-underscore name would be the safe but boring option, something like `__d_assert` or `__importc_assert`
Apr 28 2022
On 4/28/2022 1:02 AM, duser wrote:maybe `_Assert`? similar to `_Static_assert` it almost looks like something you could expect to see in a future C standard adding a prefix to the double-underscore name would be the safe but boring option, something like `__d_assert` or `__importc_assert`I like __importc_assert, except it's a bit long. I've also thought of __check() which is congruent with the compiler switch -checkxxxxx
Apr 29 2022
On Thursday, 28 April 2022 at 04:33:18 UTC, Walter Bright wrote:I put in a PR to add __assert(assign-expression) to ImportC,Unfortunately, some C compilers use __assert. Arghh!__cassert().
Apr 29 2022
On 4/27/22 21:33, Walter Bright wrote:I put in a PR to add __assert(assign-expression) to ImportC, for reasons explained in the PR: https://github.com/dlang/dmd/pull/14026 Unfortunately, some C compilers use __assert. Arghh! I seem unable to come up with a decent name. Advice welcome!Thesaurus is my friend: "affirm" looks better than "asseverate". :) Ali
Apr 29 2022