Tim wrote:
> ==>>If that is so then would not the following be more
>     efficient?
>
> my-obj: make object![         ; untested code
>   str: make string! 8192
>   _my-f: func[][
>     clear str
>     ; appends much data to string...
>     ] ; end function
>   ] ;end object
>
> Would not 'str be allocated just once and that would be during evaluation
of my-obj?

Usually, one wants the string value for use in other things. So the first
function:

        my-f: func[][
            str: make string! 8192 ; untested code
            ; appends much data to str....
            return str
            ]
is better if one wants to use the value returned by evaluationg 'my-f
multiple times in the same 'compose. Otherwise you'll end up with the same
value repeated several times. For example:

>> F: does [S: "" clear S append S random 100 S]
>> f    ; Just to show it works seemingly well enough...
== "95"
>> f
== "52"
>> f
== "80"
>> f
== "96"
>> f
== "67"
>> x: compose [(F) (F) (F)]    ; One chance in 1000000...?
== ["12" "12" "12"]
>>>> x: compose [(F) (F) (F)]    ; and again... :(
== ["71" "71" "71"]

And now with new string! value each time:
>> F: does [S: make string! 2 append S random 100 S]
>> x: compose [(F) (F) (F)]
== ["32" "67" "30"]
>> x: compose [(F) (F) (F)]    ; See! All different. :)
== ["57" "86" "35"]

I hope that helps!

Andrew Martin
ICQ: 26227169 http://valley.150m.com/
-><-

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to