>
> e wrote:
> > It looks like both would work, according to 'help try'...
> > DESCRIPTION:
> >      Tries to DO a block and returns its value or an error.
>
> > gp: try [ open/... ]
> > and
> > try [ gp: open/... ]
> >
> > should be equivalent, no?

Let me follow with what I think is going on, and you can correct me...

> You're slightly misreading the description. Have a look at the simple
> example below:
>
> >> try [1 / 0]
> ** Math Error: Attempt to divide by zero.
> ** Where: 1 / 0

This actually reduces to an error, no surprise

> >> error? try [1 / 0]
> == true
> >> error? err: try [1 / 0]
> == true

as demonstrated here...
But if I didn't catch the error with 'error? it would ab-end?

> >> probe err
> ** Math Error: Attempt to divide by zero.
> ** Where: 1 / 0
> >> err: none
> == none
> >> error? try [err: 1 / 0]
> == true
> >> probe err
> none
> == none

I think I get it... When the expression is reduced down, if the result is
type error!, it ab ends.  So I could have said:

if not error? try [gp: open/direct/binary probe join tcp:// [ip ":" port]] [
    insert gp "GNUTELLA CONNECT/0.4^/^/"]

And indeed, it works... Man this language is addictive!!!


Reply via email to