to block! or to-block
[1/6] from: ammon:rcslv at: 4-Jun-2002 20:25
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?
I generally use 'to block! in my code rather than to-block, and I began to
wonder what the reason for making the 'to-datatype functions is. Any
thoughts are always helpful to get my poor little mind out of its shelter. ;-)
Thanks!!
Ammon
[2/6] from: greggirwin:mindspring at: 6-Jun-2002 15:00
Hi Ammon,
I've wondered the same thing. I haven't dug in to see if maybe there are
some pathological evaluation situations where they would make life easier,
but I doubt it. If you look at the source for all of them, they just call
'to <type> internally.
--Gregg
[3/6] from: atruter:hih:au at: 7-Jun-2002 9:49
> Why are there specific functions for converting datatypes? Isn't 'to
good enough?
Same deal as "make function!" I suspect. Common usage patterns (eg. does,
has, func, function) have shortcuts. I also think:
to-string 1
is inherently less complex than
to string! 1
if only because you deal with one less word and don't have to use <shift>
when typing! ;). I also find that "word value" pairs come more naturally.
But hey, use whatever you feel more comfortable with (the old PERL adage of
TMTOWTDI - There's More Than One Way To Do It - applies equally well to
REBOL!).
Regards,
Ashley
[4/6] from: lmecir:mbox:vol:cz at: 7-Jun-2002 2:18
Hi Ammon,
I think, that to-datatype functions are relics from old times, when the TO
function didn't exist. I see no compelling reason for using them.
Cheers
-L
----- Original Message -----
From: "Ammon Johnson"
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?
I generally use 'to block! in my code rather than to-block, and I began to
wonder what the reason for making the 'to-datatype functions is. Any
thoughts are always helpful to get my poor little mind out of its shelter.
;-)
Thanks!!
Ammon
[5/6] 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 ]
[6/6] from: ammon:rcslv at: 8-Jun-2002 15:29
Hi,
Well, congradulations on the wedding! And thanks for taking the reply. ;-)
Thanks!!
Ammon
A short time ago, Joel Neely, sent an email stating: