Re: [perl #131877] better error message for exit("hello")

2017-08-10 Thread Joachim Durchholz

Would it be possible to special case when someone passes a string to
exit and give a better error message telling how to write that?


Maybe the error message should indicate what types are allowed.


Better yet, could exit accept a string?


That would be equivalent to `print("hello");exit(0)`.
Very little added value IMHO, but source of potential confusion: How 
will `exit($x)` use the content of `$x`, as a return code or as 
something to print? You have to check whether `$x` is an integer or not 
- and what about floating-point numbers? It could be converted to string 
or to int, and at least some programmers will expect the opposite of 
what Perl6 is doing.


TL;DR it shouldn't accept a string, that would be worse than throwing an 
error.

(IMHO etc.)


Re: [perl #131877] better error message for exit("hello")

2017-08-10 Thread Joachim Durchholz via RT
> Would it be possible to special case when someone passes a string to
> exit and give a better error message telling how to write that?

Maybe the error message should indicate what types are allowed.

> Better yet, could exit accept a string?

That would be equivalent to `print("hello");exit(0)`.
Very little added value IMHO, but source of potential confusion: How 
will `exit($x)` use the content of `$x`, as a return code or as 
something to print? You have to check whether `$x` is an integer or not 
- and what about floating-point numbers? It could be converted to string 
or to int, and at least some programmers will expect the opposite of 
what Perl6 is doing.

TL;DR it shouldn't accept a string, that would be worse than throwing an 
error.
(IMHO etc.)



[perl #131877] better error message for exit("hello")

2017-08-10 Thread via RT
# New Ticket Created by  Gabor Szabo 
# Please include the string:  [perl #131877]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=131877 >


In Python one can pass a string to the exit() function that will be
displayed and the program exited.


In Perl 6 I get:

$ perl6
To exit type 'exit' or '^D'
> exit("hello")
Cannot convert string to number: base-10 number must begin with valid
digits or '.' in '⏏hello' (indicated by ⏏)
  in block  at  line 1

Would it be possible to special case when someone passes a string to
exit and give a better error message telling how to write that?

Better yet, could exit accept a string?