Hi,

I am sure, I didn't explain the things as they should have been explained.
Here is the example, how the code could look:

Transpose: function [
    [catch]
    "Transposes Matrices"
    Matrix [block!]
] [
    Results Width Height Column
] [
    throw-on-error [
        Results: make block! Width: length? Matrix/1
        Height: length? Matrix
        repeat Index Width [
            Column: make block! Width
            foreach Row Matrix [
                insert/only tail Column Row/:Index
            ]
            insert/only tail Results Column
        ]
        Results
    ]
]

Now an example use:

>> transpose [[1 2 3] [a b c] 3]
** Script Error: Cannot use path on integer! value.
** Where: transpose [[1 2 3] [a b c] 3]

Cheers,
    Ladislav

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, October 07, 2000 2:00 AM
Subject: [REBOL] Document bug - [catch] There's a catch!


> Joel wrote:
> > > > I assume your  [catch]  was a faster way of addressing this same
> issue, by simply passing the error resulting from an empty argument list
> back to the caller.
>
> Andrew (mistakenly!!) wrote:
> > > It's a whole lot simpler and catches the error earlier and it runs
> faster.
>
> Ladislav wrote:
> > I would say, that your source is (as long as :make, :block!, :length?,
> :repeat, :foreach, :insert, :tail are normal, unchanged natives) exactly
> equivalent to the same function not having [catch] refinement, because
there
> is no Throw for it in the source.
>
> >> transpose [[1 2 3] [a b c] 3]
> ** Script Error: Cannot use path on integer! value.
> ** Where: insert/only tail Column Row/:Index
>
> Ladislav, you're right! I've read the manual on this part, Page 268, 8-26
> Function Attributes, and it reads:
> <quote>
> If the [catch] attribute is specified, errors that are thrown within the
> function are caught automatically within the function but
> (continued on next page)
> at the point where the function was used. This is useful if you are
> providing a function library (mezzanine functions) and don't want the
error
> to be displayed within your function, where where it was called:
> </Quote>
>
> But it doesn't mention that this _only_ happens if 'throw is used in the
> body of the function or one of functions the function might call.
>
> I've sent this to feedback and docs @ rebol.com so they can fix it up.
>
> Andrew Martin
> Foolishly believing the documentation! :-)
> ICQ: 26227169
> http://members.nbci.com/AndrewMartin/
> -><-
>
>
>

Reply via email to