tags:

views:

55

answers:

1

If not will this be possible in R3 ?

+1  A: 

Yes and No.

Technically, no.....Functions do not have names, they are anonymous. The same function may be assigned to more than one word, so the actual name is problematic.

do func [][print "hi world"]    ;; this function explicitly has no name at all

f1: func [] [print "yo world"]  ;; here's a single function with three names
f2: :f1
f3: :f2

In practice in some cases, Yes....You can grab the current name (if there is one) with a trick: capture an error, and the error object contains the name on the stack:

 f3: func [/local eo] [eo: disarm try [0 / 0 ] print ["name is " eo/where]]
 f4: :f3

Try it:

 >> f3
 name is  f3
 >> f4
 name is  f4

There is an exhaustive discussion here: http://www.rebol.org/ml-display-thread.r?m=rmlGLPJ

Sunanda
Hi Sunanda thanks, but then there should still be possible to reference it generically with something like self or this ?
Rebol Tutorial
Or there should be a system variable which should store this contextual info like system/options/script does.
Rebol Tutorial
Sadly, 'self means the thing itself, not the name of any word it is assigned to. This "trick" does not work with objects/contexts: probe o1: context [o1-name: get in disarm try [ 0 / 0] 'where o1-self: self]
Sunanda
Hasn't anyone suggest this to Carl even if it is in Rebol 4 I really want it :)
Rebol Tutorial