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

2017-08-10 Thread Gabor Szabo
On Thu, Aug 10, 2017 at 3:59 PM, Zoffix Znet via RT
 wrote:
> On Thu, 10 Aug 2017 02:09:30 -0700, szab...@gmail.com wrote:
>> In Python one can pass a string to the exit() function
>> Would it be possible to special case
>
> Not really keen on adding special cases to support programming-by-guessing 
> instead of reading the documentation.

I think these days it is way too much to expect people to read and
remember(!) the documentation.
At least no up-front.

However a more common case is the frequent language switching. I keep
typing Python constructs in Perl and Perl constructs in Python. Not to
mention Perl 5 vs 6 constructs. And JavaScript too.

> LTA errors is a pretty common topic, but we seem to be trying to solve the 
> problem by shooting off the hip any time someone brings something up. How 
> about a checklist for what an error must accomplish?

I have not given much thought to it, but I'd like my language to treat
me as a human. Instead of telling me I am stupid, it should give me
direction to fix the problem. Pointing at the specific paragraph in
the documentation can be part of it.

Rakudo does this quite well in some cases. In others less so.
The thing is that now that I try to recall when did Rakudo do well I
cannot really remember.
And that IMHO is a good thing.


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

2017-08-10 Thread Gabor Szabo via RT
On Thu, Aug 10, 2017 at 3:59 PM, Zoffix Znet via RT
 wrote:
> On Thu, 10 Aug 2017 02:09:30 -0700, szab...@gmail.com wrote:
>> In Python one can pass a string to the exit() function
>> Would it be possible to special case
>
> Not really keen on adding special cases to support programming-by-guessing 
> instead of reading the documentation.

I think these days it is way too much to expect people to read and
remember(!) the documentation.
At least no up-front.

However a more common case is the frequent language switching. I keep
typing Python constructs in Perl and Perl constructs in Python. Not to
mention Perl 5 vs 6 constructs. And JavaScript too.

> LTA errors is a pretty common topic, but we seem to be trying to solve the 
> problem by shooting off the hip any time someone brings something up. How 
> about a checklist for what an error must accomplish?

I have not given much thought to it, but I'd like my language to treat
me as a human. Instead of telling me I am stupid, it should give me
direction to fix the problem. Pointing at the specific paragraph in
the documentation can be part of it.

Rakudo does this quite well in some cases. In others less so.
The thing is that now that I try to recall when did Rakudo do well I
cannot really remember.
And that IMHO is a good thing.


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

2017-08-10 Thread Brandon Allbery via RT
At some point, one has to accept that this language is not Python, not call
for one's favorite Python-isms to be incorporated into the core regardless
of how it might interact with what is already there.

On Thu, Aug 10, 2017 at 8:12 AM, Aleks-Daniel Jakimenko-Aleksejev via RT <
perl6-bugs-follo...@perl.org> wrote:

> There's a little problem with it. You see, right now this works:
>
> exit "1"
>
> So we simply cannot force it to do something else with Strs because that
> can
> break existing (perfectly valid) code. We can go through a long deprecation
> cycle but it's not worth it (IMO).
>
> But it may be possible to catch X::Str::Numeric exception and print better
> message for this situation… ¯\_(ツ)_/¯
>
> On 2017-08-10 02:09:30, szab...@gmail.com wrote:
> > 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?
>
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


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

2017-08-10 Thread Brandon Allbery
At some point, one has to accept that this language is not Python, not call
for one's favorite Python-isms to be incorporated into the core regardless
of how it might interact with what is already there.

On Thu, Aug 10, 2017 at 8:12 AM, Aleks-Daniel Jakimenko-Aleksejev via RT <
perl6-bugs-follo...@perl.org> wrote:

> There's a little problem with it. You see, right now this works:
>
> exit "1"
>
> So we simply cannot force it to do something else with Strs because that
> can
> break existing (perfectly valid) code. We can go through a long deprecation
> cycle but it's not worth it (IMO).
>
> But it may be possible to catch X::Str::Numeric exception and print better
> message for this situation… ¯\_(ツ)_/¯
>
> On 2017-08-10 02:09:30, szab...@gmail.com wrote:
> > 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?
>
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net