Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: "get" function

From: henrikmk:gm:ail at: 9-Nov-2010 15:03

On Tue, Nov 9, 2010 at 4:52 AM, Peter W A Wood <pwawood-gmail.com> wrote:
> > On 9 Nov 2010, at 10:54, Duke Normandin wrote: > >> >> =46rom "REBOL/Core Users Guide - Chapter 4 - Expressions": >> >> [quote] >> print native? :if >> true >> >> Here the get returns the function for if. >> [/quote] >> >> 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, > it's not implied in native? > > What you wrote was equivalent to: > >>> print native? get 'if =A0 =A0 =A0 > true > > The : prefix denotes a get-word value, that is to say :if is a get-word. > In REBOL a get-word evaluates to the "contents" of the word. (I quoted > "contents" because depending on the type of value, the result of the > evaluation may be the value referred to in the word - as is the case > with functions). > > The section on Words in the REBOL/Core 2.3 docs is still valid - > http://www.rebol.com/docs/core23/rebolcore-4.html#section-5 > > Regards > > Peter
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 == make function! [.... There are better examples, but that is the general idea. -- Regards, Henrik Mikael Kristensen