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

[REBOL] Re: how to call HELP on an object method ?

From: greggirwin:mindspring at: 23-May-2003 11:10

Hi Marc, MM> Any idea on how to call HELP on an object method ??? There are a number of ways you could approach this. A simple one would be: obj-help: func [word] [help :word] obj-help in o 'm1 Another way, that I have played with, for use in a general set of objects used as a library, is to define a HELP function in a prototype object and let all the others use that. REBOL [ Title: "lib-kernel" Author: "Gregg Irwin" Email: [greggirwin--acm--org] Version: 0.0.1 Comment: {Base object for libraries.} ] lib-kernel: make object! [ ;-- This is used to make the help functions in the sub-libraries. ; They can redefine it, of course, but this gives us a base of ; functionality. ?: help: func [ "Shows help for the object." /with "Means you want help for one, specific word." word "The word you want help for." /local value ][ either with [ value: in get 'self :word either none? :value [print rejoin [:word " is not a word in library."]] [system/words/help :value] ][ ;?? It might be better to show just the interface for each ; function and/or an overview help text for the object. foreach word help-words [ ; a) ;value: in get 'self :word ;system/words/help :value ; b) print either function? value: get in get 'self word [ [word mold third :value] ][ [word mold :value] ] print to-string array/initial 66 "-" ] ] ] ;-- List of words defined in the object. words: does [next first self] ;-- By default, help will return help for all words in the object. ; You can override this to show help for just a subset of words. help-words: :words ] Then you just do this: obj: make lib-kernel [ m1: function [ "help on m1" ][][ print "I am m1" ] ] obj/help ; prints help for all methods in obj obj/help/with 'm1 ; prints help just for m1 You could also modify the standard HELP function to allow use of paren! values or something, or build a special function and dialect for getting really specific control. HTH! -- Gregg