[REBOL] Re: to block! or to-block
From: joel:neely:fedex at: 10-Jun-2002 6:49
Hi, Ammon,
Sorry to be so slow in responding...
We're getting ready for a wedding (my older son) and in crunch mode
at work, so spare time is in short supply right now.
Ammon Johnson wrote:
> Hi,
>
> Why are there specific functions for converting datatypes?
> Isn't 'to good enough? are there performance differences, or
> evaluation differences? Any insight anyone? Joel, could you run
> some benchmarks to see if there is a difference that way?
>
No need for benchmarks. "Use the SOURCE, Luke!"
>> source to-integer
to-integer: func [
"Converts to integer value."
value "Value to convert"
][
to integer! :value
]
>> source to-block
to-block: func [
"Converts to block value."
value "Value to convert"
][
to block! :value
]
>>
(manually reformatted for wrap-elimination)
Based on the above, I'd expect no evaluation differences, but
using the to-foo forms adds the overhead of a wrapper function
to every eval. Hardly worth it to save one keystroke, IMHO.
-jn-
--
; Joel Neely joeldotneelyatfedexdotcom
REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
| e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]