www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18614] New: dmd source uses bool return inconsistently (true


          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: nobody puremagic.com
          Reporter: timothee.cour2 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

Mar 14 2018