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

[REBOL] Re: Reflectivity: How a function can know its own name ?

From: joel:neely:fedex at: 24-Mar-2002 13:05

Hi, Laplace, laplace wrote:
> In rebol doc, it is said that function can know himself > (its argument, its code) but I can't see how it can know > just its name : it would seem logical that it is the firts > thing it should know :) ? >
Given a value of type FUNCTION! it is possible to acquire its argument list and body.
>> foo: func [x [integer!] y [string!]] [append/dup copy "" y x] >> first :foo
== [x y]
>> second :foo
== [append/dup copy "" y x]
>> third :foo
== [x [integer!] y [string!]] However... A function doesn't have a name. A function is a value, and zero, one, or more words can refer to that value, but "name" is not an attribute of a function in REBOL. For the sake of analogy, it's like having a reference to a string value and asking for its "name". -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 ]