On Tue, Nov 9, 2010 at 4:52 AM, Peter W A Wood <[email protected]> wrote:
>
>
> On 9 Nov 2010, at 10:54, Duke Normandin wrote:
>
>>=3D20
>> =3D46rom "REBOL/Core Users Guide - Chapter 4 - Expressions":
>>=3D20
>> [quote]
>> print native? :if
>> true
>>=3D20
>> Here the get returns the function for if.
>> [/quote]
>>=3D20
>> Is this a typo? I don't see the "get" function being used. Is it
>> implied in native?
>
> No, it's not a typo. The "get" function (or an equivalent) was used. No, =
=3D
> it's not implied in native?
>
> What you wrote was equivalent to:
>
>>> print native? get 'if =A0 =A0 =A0=3D20
> true
>
> The : prefix denotes a get-word value, that is to say :if is a get-word. =
=3D
> In REBOL a get-word evaluates to the "contents" of the word. (I quoted =
=3D
> "contents" because depending on the type of value, the result of the =3D
> evaluation may be the value referred to in the word - as is the case =3D
> with functions).
>
> The section on Words in the REBOL/Core 2.3 docs is still valid - =3D
> http://www.rebol.com/docs/core23/rebolcore-4.html#section-5
>
> Regards
>
> Peter=3D20

It's also a nice shortcut for a security measure to avoid running
functions, if you are processing untrusted input, where it would be
possible to inject a function and you don't want to limit the possible
datatypes in the function argument.

my-func: func [data] [
  case [
    any-function? :data [:data] ; pass it through
    series? :data [parse :data my-rules] ; process it
  ]
]

my-func some-dangerous-function
=3D=3D make function! [....

There are better examples, but that is the general idea.

--=20
Regards,
Henrik Mikael Kristensen
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to