What's the string rep of return -error?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

What's the string rep of return -error?

Larry McVoy-2
Since EIAS, shouldn't I be able to trace and log all the inputs and outputs
of a proc (by redefining proc)?

If so, when a proc does return -error, what's the string rep of that?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Colin McCormack-3

Larry,

EIAS is a simplification. It's actually "Every Value Is A String."

Colin


On Fri, 2 Jun. 2017, 16:03 Larry McVoy, <[hidden email]> wrote:
Since EIAS, shouldn't I be able to trace and log all the inputs and outputs
of a proc (by redefining proc)?

If so, when a proc does return -error, what's the string rep of that?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Christian Gollwitzer
In reply to this post by Larry McVoy-2
Am 02.06.17 um 08:48 schrieb Larry McVoy:

> On Fri, Jun 02, 2017 at 08:39:12AM +0200, Christian Gollwitzer wrote:
>> Am 02.06.17 um 08:33 schrieb Larry McVoy:
>>> Since EIAS, shouldn't I be able to trace and log all the inputs and outputs
>>> of a proc (by redefining proc)?
>>>
>>> If so, when a proc does return -error, what's the string rep of that?
>>
>> It is the error message. In C you do
>>
>> Tcl_SetObjResult(interp, Tcl_NewSTrinGObj("my message", -1));
>> return TCL_ERROR;
>>
>> A procedure in Tcl returns both a string and a return code.
>
> Ah.  So no string rep, eh?
>

I'm very thankful that Tcl implements exceptions rather than checking of
return codes for every potentially failing command, like evry modern
language does it - even C++. iostreams are a notable exception (no pun
intended), and they bite many people. Silently failing is the worst
possible behaviour.

        Christian

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Larry McVoy-2
On Fri, Jun 02, 2017 at 08:53:24AM +0200, Christian Gollwitzer wrote:

> Am 02.06.17 um 08:48 schrieb Larry McVoy:
> >On Fri, Jun 02, 2017 at 08:39:12AM +0200, Christian Gollwitzer wrote:
> >>Am 02.06.17 um 08:33 schrieb Larry McVoy:
> >>>Since EIAS, shouldn't I be able to trace and log all the inputs and outputs
> >>>of a proc (by redefining proc)?
> >>>
> >>>If so, when a proc does return -error, what's the string rep of that?
> >>
> >>It is the error message. In C you do
> >>
> >> Tcl_SetObjResult(interp, Tcl_NewSTrinGObj("my message", -1));
> >> return TCL_ERROR;
> >>
> >>A procedure in Tcl returns both a string and a return code.
> >
> >Ah.  So no string rep, eh?
>
> I'm very thankful that Tcl implements exceptions rather than checking of
> return codes for every potentially failing command, like evry modern
> language does it - even C++. iostreams are a notable exception (no pun
> intended), and they bite many people. Silently failing is the worst possible
> behaviour.

That's nice.

So no string rep for return -error?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Colin McCormack-3
By default, [return] arranges for the enclosing script to return a value.  That value is representable as a string, per EIAS or the more correct EVIAS.  [return -code error] etc does not arrange for the enclosing script to return a value, but rather raises an exception.  An exception is not a value, it is an exception.  An exception may be converted to a value (which is representable as a string) by means of the [catch] and the [try] commands.

Happy to help.
Colin

On Fri, 2 Jun 2017 at 16:27 Larry McVoy <[hidden email]> wrote:
On Fri, Jun 02, 2017 at 08:53:24AM +0200, Christian Gollwitzer wrote:
> Am 02.06.17 um 08:48 schrieb Larry McVoy:
> >On Fri, Jun 02, 2017 at 08:39:12AM +0200, Christian Gollwitzer wrote:
> >>Am 02.06.17 um 08:33 schrieb Larry McVoy:
> >>>Since EIAS, shouldn't I be able to trace and log all the inputs and outputs
> >>>of a proc (by redefining proc)?
> >>>
> >>>If so, when a proc does return -error, what's the string rep of that?
> >>
> >>It is the error message. In C you do
> >>
> >>    Tcl_SetObjResult(interp, Tcl_NewSTrinGObj("my message", -1));
> >>    return TCL_ERROR;
> >>
> >>A procedure in Tcl returns both a string and a return code.
> >
> >Ah.  So no string rep, eh?
>
> I'm very thankful that Tcl implements exceptions rather than checking of
> return codes for every potentially failing command, like evry modern
> language does it - even C++. iostreams are a notable exception (no pun
> intended), and they bite many people. Silently failing is the worst possible
> behaviour.

That's nice.

So no string rep for return -error?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Alexandre Ferrieux
In reply to this post by Larry McVoy-2
On Fri, Jun 2, 2017 at 8:56 AM, Larry McVoy <[hidden email]> wrote:

> On Fri, Jun 02, 2017 at 08:53:24AM +0200, Christian Gollwitzer wrote:
>> Am 02.06.17 um 08:48 schrieb Larry McVoy:
>> >On Fri, Jun 02, 2017 at 08:39:12AM +0200, Christian Gollwitzer wrote:
>> >>Am 02.06.17 um 08:33 schrieb Larry McVoy:
>> >>>Since EIAS, shouldn't I be able to trace and log all the inputs and outputs
>> >>>of a proc (by redefining proc)?
>> >>>
>> >>>If so, when a proc does return -error, what's the string rep of that?
>> >>
>> >>It is the error message. In C you do
>> >>
>> >>    Tcl_SetObjResult(interp, Tcl_NewSTrinGObj("my message", -1));
>> >>    return TCL_ERROR;
>> >>
>> >>A procedure in Tcl returns both a string and a return code.
>> >
>> >Ah.  So no string rep, eh?
>>
>> I'm very thankful that Tcl implements exceptions rather than checking of
>> return codes for every potentially failing command, like evry modern
>> language does it - even C++. iostreams are a notable exception (no pun
>> intended), and they bite many people. Silently failing is the worst possible
>> behaviour.
>
> That's nice.
>
> So no string rep for return -error?

Nope. OK/ERROR is out of band wrt values. But we know you know.

-Alex

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Colin McCormack-3
What exists in Tcl which is not a value is a really very interesting ontological question.

Larry, though, is not interested in ontology.

Larry is a metaphysician pursuing a platonic ideal NUL.  Per Nietzsche, the goal of metaphysics is not to solve problems, but to allow its user to strike a forlorn pose.

Colin

On Fri, 2 Jun 2017 at 17:42 Alexandre Ferrieux <[hidden email]> wrote:
On Fri, Jun 2, 2017 at 8:56 AM, Larry McVoy <[hidden email]> wrote:
> On Fri, Jun 02, 2017 at 08:53:24AM +0200, Christian Gollwitzer wrote:
>> Am 02.06.17 um 08:48 schrieb Larry McVoy:
>> >On Fri, Jun 02, 2017 at 08:39:12AM +0200, Christian Gollwitzer wrote:
>> >>Am 02.06.17 um 08:33 schrieb Larry McVoy:
>> >>>Since EIAS, shouldn't I be able to trace and log all the inputs and outputs
>> >>>of a proc (by redefining proc)?
>> >>>
>> >>>If so, when a proc does return -error, what's the string rep of that?
>> >>
>> >>It is the error message. In C you do
>> >>
>> >>    Tcl_SetObjResult(interp, Tcl_NewSTrinGObj("my message", -1));
>> >>    return TCL_ERROR;
>> >>
>> >>A procedure in Tcl returns both a string and a return code.
>> >
>> >Ah.  So no string rep, eh?
>>
>> I'm very thankful that Tcl implements exceptions rather than checking of
>> return codes for every potentially failing command, like evry modern
>> language does it - even C++. iostreams are a notable exception (no pun
>> intended), and they bite many people. Silently failing is the worst possible
>> behaviour.
>
> That's nice.
>
> So no string rep for return -error?

Nope. OK/ERROR is out of band wrt values. But we know you know.

-Alex

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Donald Porter
In reply to this post by Larry McVoy-2

If so, when a proc does return -error, what's the string rep of that?

% puts [catch {apply {{} {return -code error}}}]
1

DGP


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Donal K. Fellows-2
In reply to this post by Christian Gollwitzer
On 02/06/2017 07:53, Christian Gollwitzer wrote:
> I'm very thankful that Tcl implements exceptions rather than checking of
> return codes for every potentially failing command, like evry modern
> language does it - even C++.

Tcl's implementation does it by return code checking. But that's the
implementation, not the specification. When an error is returned, the
representation of the error message is whatever it was when it was
created, but it's usually some type of string. The error code itself
does not form part of the representation of the message at all.

Donal.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core

donal_k_fellows.vcf (241 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Kevin Kenny-6
On Fri, Jun 2, 2017 at 10:24 AM, Donal K. Fellows <[hidden email]> wrote:
On 02/06/2017 07:53, Christian Gollwitzer wrote:
I'm very thankful that Tcl implements exceptions rather than checking of
return codes for every potentially failing command, like evry modern
language does it - even C++.

Tcl's implementation does it by return code checking. But that's the
implementation, not the specification. When an error is returned, the
representation of the error message is whatever it was when it was
created, but it's usually some type of string. The error code itself
does not form part of the representation of the message at all.
 
Moreover, if we're asking "what is the string rep of a command's
return state, taking into account all possible exceptions", then it's
the message plus the option dictionary, both of which do have
string values.

We can see that in:
    % catch {return -code error Whoops!} message options
    2      <--- 'return'
    % set options
    -code 1 -level 1 -errorcode NONE

Note that NONE is a default error code, and different from a NULL.
We do have null error codes when no error has occurred.
As is conventional in Tcl, they're represented by the absence
of an option in the dictionary, as in the following, representing
an exception that is not an error:

    % catch {break} message options
    3
    % set options
    -code 3 -level 0




   

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Larry McVoy-2
On Fri, Jun 02, 2017 at 11:30:59AM -0400, Kevin Kenny wrote:

> On Fri, Jun 2, 2017 at 10:24 AM, Donal K. Fellows <
> [hidden email]> wrote:
>
> > On 02/06/2017 07:53, Christian Gollwitzer wrote:
> >
> >> I'm very thankful that Tcl implements exceptions rather than checking of
> >> return codes for every potentially failing command, like evry modern
> >> language does it - even C++.
> >>
> >
> > Tcl's implementation does it by return code checking. But that's the
> > implementation, not the specification. When an error is returned, the
> > representation of the error message is whatever it was when it was
> > created, but it's usually some type of string. The error code itself
> > does not form part of the representation of the message at all.
> >
>
> Moreover, if we're asking "what is the string rep of a command's
> return state, taking into account all possible exceptions", then it's
> the message plus the option dictionary, both of which do have
> string values.
>
> We can see that in:
>     % catch {return -code error Whoops!} message options
>     2      <--- 'return'
>     % set options
>     -code 1 -level 1 -errorcode NONE
>
> Note that NONE is a default error code, and different from a NULL.
> We do have null error codes when no error has occurred.
> As is conventional in Tcl, they're represented by the absence
> of an option in the dictionary, as in the following, representing
> an exception that is not an error:
>
>     % catch {break} message options
>     3
>     % set options
>     -code 3 -level 0

Please tell me the string rep of return -error such that I can do

proc throw_error
{
        return $string_rep_of_return-error
}

such that it is different than a proc that returns a string and it
returns the completely valid string of "-error" or whatever it is
that return wants to throw an error.

The point is that when you say "return -error" it does something, it
throws an error.  But if I say

        return "-error"

it does not.  So what's the string that does throw the error?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the string rep of return -error?

Peter da Silva-2
On 6/2/17, 10:39 AM, "Larry McVoy" <[hidden email]> wrote:
> Please tell me the string rep of return -error such that I can do
>  
>   proc throw_error
>   {
>   return $string_rep_of_return-error
>   }

Don’t you mean “return {*}$string_rep_of_return-error” ?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Loading...