Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Function question
Pages: [1] Print
Author Topic: Function question  (Read 395 times)
kpeters
Newbie
*
Offline Offline

Posts: 24


View Profile
Function question
« on: July 31, 2007, 04:09:22 PM »


Given a function as in:

go-first: does [ print "go-first" ]

How can I get it to print its name without having to supply it as a iteral to print?

TIA,
Kai
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: Function question
« Reply #1 on: August 01, 2007, 02:06:27 AM »

Short answer: Functions do not have a name.

Long answer: hopefully someone else will have the time for the long answer...
Logged
Sunanda
Full Member
***
Offline Offline

Posts: 110


View Profile
Re: Function question
« Reply #2 on: August 01, 2007, 06:58:35 AM »

Functions do not have names as Gabriele says....They are assigned to words which is a subtly different thing. You function could be assigned to many words, or none:

Code:
    go-first: go-next: go-last: does [print "who am i?" ]
    go-fifth: :go-next

    blk: copy []
    append blk does [print "who am i?" ]
    blk/1

But execution does have context, so this works in R2:

Code:
    go-first: does [print get in disarm try [0 / 0] 'where ]
    go-first
    == go-first

It is not guaranteed to work in later versions of REBOL as the error handling may be overhauled.
Logged
kpeters
Newbie
*
Offline Offline

Posts: 24


View Profile
Re: Function question
« Reply #3 on: August 01, 2007, 06:30:14 PM »

Thank you both for your time!

Regards,
Kai
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Function question
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2008, 10:42:15 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2295 Posts in 593 Topics by 3765 Members
Latest Member: vk1n0vce

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc