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

[REBOL] Re: Hack

From: joel:neely:fedex at: 28-Dec-2001 6:22

Hi, Sunanda, [SunandaDH--aol--com] wrote:
> I'm disappointed with Rebol that something as simple as > "What's the name of the current function?" isn't easily > available, something like: > > print System/Current/Function-name >
Unfortunately, I'm too dense to parse the phrase "name of the current function", at least WRT REBOL. Consider the following:
>> f: reduce [
[ func [n] [n + 1] [ func [n] [n * n - n + 1] [ func [n] [n * n * n + 3] [ ] == [func [n][n + 1] func [n][n * n - n + 1] func [n][n * n * n + 3]]
>> foreach ff f [print ff 3]
4 7 30
>>
None of those functions even *have* a name, or rather they all have the same name, or ... hmmmm ;-) The real issue is that functions are first-class values in REBOL (i.e., just as with strings or numbers, they can be created at will, passed as arguments, returned as the result of an evaluation, etc...) As a consequence of this fact, it is as meaningful/less to talk about the "name of the current function" as it is to talk about the "name of the current 2", IMHO. -- ; sub REBOL {}; sub head ($) {@_[0]} REBOL [] # despam: func [e] [replace replace/all e ":" "." "#" "@"] ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"} print head reverse despam "moc:xedef#yleen:leoj" ;