www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - iz v0.6.18 - Now with a modern, fast, safe, getopt-like function

reply Basile B. <b2.temp gmx.com> writes:
Last time i promoted my stuff here there were two compiler/Phobos 
bugs preventing to activate this nice getopt-like function.

specs:

- It's based on UDA.
- It supports multiple locations for UDA-fied functions and 
variables.
- It doesn't use pointers, UDA-ified variable are accessed 
without intermediary.
- It's faster than the phobos one (although getopt is never a 
bottleneck)
- It's ` safe` and can be even `nothrow`

It could be easily added to phobos (just need to convert some 
EnumSet to BitFlag).

- code: 
https://github.com/BBasile/iz/blob/master/import/iz/options.d#L596
- DUB: https://code.dlang.org/packages/iz
- doc: 
https://iz.dpldocs.info/v0.6.18/iz.options.handleArguments.html
- cool demo: 
https://github.com/BBasile/Coedit/blob/master/dastworx/src/main.d#L18

Note that despite of the run-time compatibility mention in the 
README, this module is part of a subset of IZ that can be used 
without all the concept of Nogc as used in iz. (at some point i 
should split the twos parts).
May 27 2018
parent Basile B. <b2.temp gmx.com> writes:
On Monday, 28 May 2018 at 00:53:45 UTC, Basile B. wrote:
 Last time i promoted my stuff here there were two 
 compiler/Phobos bugs preventing to activate this nice 
 getopt-like function.

 specs:

 - It's based on UDA.
 - It supports multiple locations for UDA-fied functions and 
 variables.
 - It doesn't use pointers, UDA-ified variable are accessed 
 without intermediary.
 - It's faster than the phobos one (although getopt is never a 
 bottleneck)
 - It's ` safe` and can be even `nothrow`

 It could be easily added to phobos (just need to convert some 
 EnumSet to BitFlag).

 - code: 
 https://github.com/BBasile/iz/blob/master/import/iz/options.d#L596
 - DUB: https://code.dlang.org/packages/iz
 - doc: 
 https://iz.dpldocs.info/v0.6.18/iz.options.handleArguments.html
 - cool demo: 
 https://github.com/BBasile/Coedit/blob/master/dastworx/src/main.d#L18

 Note that despite of the run-time compatibility mention in the 
 README, this module is part of a subset of IZ that can be used 
 without all the concept of Nogc as used in iz. (at some point i 
 should split the twos parts).
such attribute-based getopt is now used in styx driver e.g - [here](https://gitlab.com/styx-lang/styx/-/blob/master/src/styx/session.sx?ref_type=heads#L107) - [here](https://gitlab.com/styx-lang/styx/-/blob/master/src/styx/session.sx?ref_type=heads#L492) In styx now I just do ``` if !getOpt![(session, DriverOptions, MachineTarget)](processCeeArgs(argc, argv), &onArgument) do return 1; ``` At some point we forgot what we wanted to do in D ;)
Nov 16 2023