[REBOL] Transpose Re:(2)
From: al:bri:xtra at: 6-Oct-2000 13:40
> Nice choice of names...
> (but I MUST remember to ask you about the caps)
Why capitals? Here's the Transpose function again:
Transpose: function [
Results Width Height Column
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
Note that every word that is defined here is in Title case. Also note that
every common word that's in Rebol like 'insert, '/only, 'length? etcetera
are in lower case. What's _important_ is signalled by the Title case words.
Here's Transpose again but in a sea of lower case.
transpose: function [
results width height column
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
Can you _easily_ see if I've made a mistake? What are the important words?
> My real question here is this, if we collectively are going to build up a
small pile of useful extensions, would it be good to have some conventions
re defensive programming...
Don't bother with defensive programming. It's just more stuff to debug and
put right Put the [catch] attribute in and let the problem in the code be
caught as early as possible. I'd still use 'try around disk and net i/o, as
this makes sense. And the argument type specifiers are good as well.
> 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
It's a whole lot simpler and catches the error earlier and it runs faster.
Look what happens when I go to sleep! :-)