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

[REBOL] Re: ?

From: ryanc:iesco-dms at: 10-Jan-2001 18:33

Hi SpliFF, Your answer is hidden in the source of these functions:
>> source help
help: func [ "Prints information about words and values." 'word [any-type!] /local value args item name refmode types attrs rtype ] ....
>> source source
source: func [ "Prints the source code for a word." 'word [word!] ] .... Notice that they ask for 'word literally, instead of just word. In the function header "dialect" the literial notation ' has basically the same meaning--dont evaluate. So instead of the parameter being evaluated before assignment within the function, it is just grabbed as-is. Same effect as if you had used a literal notation on the parameter itself. To further demonstrate, we can look at the native function 'and:
>> source and
and: native [ "Returns the first value ANDed with the second." value1 [logic! number! char! tuple!] value2 [logic! number! char! tuple!] ] Notice its values are not asked for literally, and therefore will be evaluated prior to assignment internally within the function. --Ryan SpliFF wrote:
> I was wondering how '? (or 'help) can take a word as an input without the > word or it's function being evaluated first. Rebol evaluates from > right-to-left as in: > > >> return-string: does [ print "ABC" return " A string! "] > >> print trim return-string > ABC > A string! > > In that example 'return-string is evaluated first (I think), then 'trim, > then 'print. So what about: > > >> ? return-string > USAGE: > RETURN-STRING > > DESCRIPTION: > (undocumented) > > If this followed the same rule as before then the string "ABC" should have > been printed before the help text. Since '? isn't a native function I > can't see how it can break the standard convention. I thought > > >> source ? > > ... would provide an answer but the output just confused the hell outta > me. I have tried to write functions like this in the past but never had > any success. Clearly my concecpt of the standard convention must be wrong. > Could somebody clarify it for me in plain english please. > > SpliFF > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst 707-468-5400 I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world. -Einstein