digitalmars.D.learn - Question about publishing a useful function I have written
- Cecil Ward (30/30) Jul 14 2020 I have written something which may or may not be novel and I’m
- Max Haughton (4/9) Jul 14 2020 GitHub is the best place to publish code. Does GDC actually use
- Cecil Ward (22/32) Jul 15 2020 On Tuesday, 14
- Andre Pany (11/44) Jul 15 2020 This is by intention. While exceptions are used for resources
- 9il (4/6) Jul 14 2020 https://github.com/libmir/mir-core/blob/master/source/mir/utility.d#L29
- Cecil Ward (2/11) Jul 15 2020 Brilliant. Many thanks.
- Jacob Carlborg (5/6) Jul 15 2020 As others have already said, on GitHub. Then as a Dub package as well [1...
I have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s the best way to publish a D routine ? It is called void assume( bool condition ) nothrow nogc safe for example: assume( x < 100 ); or assume( y != 0 ); It generates no code at all, but t does tell the gdc compiler that the given condition is true and so later code generation may assume that truth in all code generation. So for example, given the assumes above, if ( x==200) is false and no code is generated for the if-true basic block. It might look a bit like assert but it isn’t the same thing. I think assert is disabled in full release build and is only there in debug mode, is that correct? Also assert generates code in that it calls panic or hits a ud2 or whatever, whereas assume is also zero code. Does anyone know if this has already been published by someone else? Unfortunately at the moment it only works with gdc as it relies on functions that are gdc-specific for its implementation. However I could use conditional compilation to simply set up a null implementation for other compilers. I’d like to get it implemented with ldc if I can. If anyone would like to give assume a try with gdc, then shout and I’ll try and find some way of getting it to you easily.
Jul 14 2020
On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote:I have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s the best way to publish a D routine ? [...]GitHub is the best place to publish code. Does GDC actually use the optimization? I tried something like that before but I couldn't seem to get it to work properly.
Jul 14 2020
On Tuesday, 14 July 2020 at 23:10:28 UTC, Max Haughton wrote:On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote:On Tuesday, 14 ] I just tried an experiment. It seems that in release mode assert()s are realised as absolutely nothing at all, and so the _conditions_ in the asserts are not declared. So later generated code does not have the benefit of knowledge of asserted truth conditions in release mode. So in release mode, without these truth conditions being established, the code generated (apart from the asserts’ code) can be _worse than in debug mode_, which seems bizarre, but it’s true. for example assert( x < 100 ); … if ( x==200 ) // <— evaluates to false _at compile time_ { // no code generated for this block in debug mode, // but is generated in release mode } … if ( x < 100 ) // <— no code generated for if-test as cond == true at compile-timeI have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s the best way to publish a D routine ? [...]GitHub is the best place to publish code. Does GDC actually use the optimization? I tried something like that before but I couldn't seem to get it to work properly.
Jul 15 2020
On Wednesday, 15 July 2020 at 09:31:27 UTC, Cecil Ward wrote:On Tuesday, 14 July 2020 at 23:10:28 UTC, Max Haughton wrote:This is by intention. While exceptions are used for resources like user input/file system/network,... you use asserts to validate your code. When you publish your code to the world, the assertions have "done" their work and there is no need to include them in a release build. Cases where you need asserts in release builds are an indicator, that you should have used exceptions instead. Kind regards AndreOn Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote:On Tuesday, 14 ] I just tried an experiment. It seems that in release mode assert()s are realised as absolutely nothing at all, and so the _conditions_ in the asserts are not declared. So later generated code does not have the benefit of knowledge of asserted truth conditions in release mode. So in release mode, without these truth conditions being established, the code generated (apart from the asserts’ code) can be _worse than in debug mode_, which seems bizarre, but it’s true. for example assert( x < 100 ); … if ( x==200 ) // <— evaluates to false _at compile time_ { // no code generated for this block in debug mode, // but is generated in release mode } … if ( x < 100 ) // <— no code generated for if-test as cond == true at compile-timeI have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s the best way to publish a D routine ? [...]GitHub is the best place to publish code. Does GDC actually use the optimization? I tried something like that before but I couldn't seem to get it to work properly.
Jul 15 2020
On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote:Does anyone know if this has already been published by someone else?https://github.com/libmir/mir-core/blob/master/source/mir/utility.d#L29 We test LDC and DMC. CI needs an update to be actually tested with GDC.
Jul 14 2020
On Wednesday, 15 July 2020 at 02:25:42 UTC, 9il wrote:On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote:Brilliant. Many thanks.Does anyone know if this has already been published by someone else?https://github.com/libmir/mir-core/blob/master/source/mir/utility.d#L29 We test LDC and DMC. CI needs an update to be actually tested with GDC.
Jul 15 2020
On 2020-07-14 23:58, Cecil Ward wrote:What’s the best way to publish a D routine ?As others have already said, on GitHub. Then as a Dub package as well [1]. [1] https://code.dlang.org -- /Jacob Carlborg
Jul 15 2020