[REBOL] Re: Updates to hof script
From: jan:skibinski:sympatico:ca at: 16-Nov-2002 11:23
> Hi Jan,
> Accordingly, the following application is legal:
> map-2 :+ [1 2 3] [1 1 1]
> == [2 3 4]
> Now, if you look again at the original definition:
> > Mapping two series via binary function:
> > ((a -+ b -+ c) -+ [a] -+ [b] -+ [c])
> How would you note that the result of (adding two decimals) yields a decimal
> unless, the operation overflows, and the result is coerced to a float instead of a
For all I know a decimal in Rebol is a float.
If you meant integer, then yes I cannot predict
what sort of casting Rebol will do during its
runtime. But since certain objects cannot be converted
then Rebol will complain - sometimes very very
late, somewhere deeply inside some loop. My type
checker could eliminate some classes of such
problems. Compared to Rebol, Haskell would do
a thorough static typechecking first - discovering
such bugs and not even letting me start
But this is not the point. I am not trying to predict
what Rebol will in fact do during runtime, I only
wish to provide tools that suppose to help us with
documenting complex functions, and to let us check
validities of some classes of expressions before
they are even executed.
Look, I am not trying to impose any restrictions
on Rebol - it's fine as it is with all this casting,
mixed type arithmetic, mixed types inside blocks, etc.
But when I write my own function that accepts
an array of specific types, such as decimals
I want to document it as such and tell the user
up front that they should better use decimals,
not the strings or a mixture of both.
If my intention would be to accept any mixed
array, then I would document it as such, [any].
Typeless systems of Smalltalk kind, or weakly
(dynamicly) typed systems such as Rebol are the
blessing and the curse - compared to the strong
static type systems.
I've been on both sides of the border, and I know
all about disadvantages and advantages of such
languages. As I said, Rebol is fine for what
it supposed to be. It provides freedom of
choices, of creating little universes, such as
dialects, to impose extra rules of the game.
All the best,