Why doesn't main () return value set exitcode in dart?

Dart should be pragmatic, intuitive, etc. I wonder why top-level main () does not set exitcode if int is returned?

I know you can install it through dart:io.exitCode=or use dart:io.exit().

Question: why did the language developers decide to abandon such a popular agreement

#!/path/to/dart --checked
int main() {
  int myExitCode = 5;
  return myExitCode;
}

It returns 0 (as described in the documentation ), but in the command-line world this is just plain stupid. It does not even warn you (compiler check mode, dartanalyzer). Script just silently return 0. Is there any justification behind this?

UPDATE:

offer error: https://code.google.com/p/dart/issues/detail?id=21639

+4
3

, main() , , . exit dart:io .

import 'dart:io';

 main(){
    exit(42);
 }

API : https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:io#id_exit

+6

main() Dart void, . . main() , exit, . , Dart VM CLI, . main(). , dart:io, CLI VM.

+6

, main() ( , +1), .

, main(List<String> args) , dart main(List<String> args).

On the other hand, support for the main-return-sets-exitCode function could tighten the heart of the dart (as top-level main () is processed) to dart:io, which is not available in browsers. However, I personally don’t think it would be so bad as with such wired and unexpected behavior as shown in the interrogation code.

0
source

All Articles