Hi Ryan

Here is a short answer, others may wish to expand. When issued in the global
context, both methods give the same results. But within the block defining
an object, they do not:

>> ob: make object! [ f1: func [x][x * x] set 'f2 func [x][x + x]]
>> probe ob

make object! [
    f1: func [x][x * x]
]
; notice that only f1 is defined within the object, f2 is global

>> f2 4
== 8
>> ob/f1 4
== 16
>>
Using a setword causes the function to be defined within the object. Using
the 'set function does not, instead, the word naming the function will be
defined in the first ancestor context where it has already been defined, or
if the word is previously undefined, in the global context.

This behavior of 'set is actually very useful for exporting functions from
objects, while in the func definition all of the object vars are available
to it.

HTH
-Larry

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 15, 2001 2:49 PM
Subject: [REBOL] set


> Reading the REBOL/Core manual, I am still uncertain as to what 'set
> accomplishes. I noticed these two functions in a recent post, one using
> 'set and the other not using 'set. What does 'set accomplish?
>
>     exec: func [series [series!]] [
>         if error? try [return do series] [
>             join exec_start [series exec_end]]]
>
>     set 'stringcompose func [
>         {Evaluates a string of expressions, only evaluating
>             executable parens, and returns a block.}
>         Text [String!]] [
>         clear buffer
>         parse/all Text rule
>         buffer]
>
> Ryan C. Christiansen
> Web Developer
>
> Intellisol International
> 4733 Amber Valley Parkway
> Fargo, ND 58104
> 701-235-3390 ext. 6671
> FAX: 701-235-9940
> http://www.intellisol.com
>
> Global Leader in People Performance Software
>
> _____________________________________
>
> Confidentiality Notice
> This message may contain privileged and confidential information. If you
> think, for any reason, that this message may have been addressed to you in
> error, you must not disseminate, copy or take any action in reliance on
it,
> and we would ask you to notify us immediately by return email to
> [EMAIL PROTECTED]
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.

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

Reply via email to