https://issues.dlang.org/show_bug.cgi?id=18614

          Issue ID: 18614
           Summary: dmd source uses bool return inconsistently (true
                    should mean success)
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: timothee.co...@gmail.com

usual convention is that a bool return function should return true on sucess
(makes it easy with `assert(run_fun(args))`

it's what's also commonly used, eg: core.runtime.Runtime.{intialize,terminate}
etc and also on parts of dmd (eg: override bool overloadInsert(Dsymbol s):
Return true if successful)

however we have these oddities in dmd:

```
// src/dmd/root/response.d:207:22
 * Returns:
 *   0   success
 *   !=0   failure (argc, argv unchanged)
 */
bool response_expand(Strings* args)
```
(also suspicious (prob historical reasons) because should be false and true,
not 0 and !=0)


and also these:
`Returns true if error`
(9 occurrences in dmd source code)

we should replace each such example with the correct convention, it's confusing
when reading corresponding code (especially caller code). Not a problem to
change these since the code is not used outside of this repo

--

Reply via email to