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

Test, please ignore

 [1/1] from: volker::nitsch::gmail::com at: 2-Aug-2005 1:24


---------- Forwarded message ---------- From: Volker Nitsch <[volker--nitsch--gmail--com]> Date: Aug 2, 2005 1:19 AM Subject: test To: ich <[volker--nitsch--gmail--com]> Hi Tim, On 8/1/05, Tim Johnson <[tim--johnsons-web--com]> wrote:
> * Anton Rolls <[antonr--lexicon--net]> [050801 01:38]: > >
<<quoted lines omitted: 21>>
> of kblists... > tim
Maybe looking at other languages and showing how to do that in rebol is not to bad for bilinguists. After all rebol can do pretty conventional oops.. And i would learn what return ' %s %s,' % (name,dispatch[layout['type']]) does! :) So lets enter a lesson of Dr Rebols tutorial SQUEEZING CODE LIKE A PYTHON! Ok, first lets enter the area of rebol-psychology. Did you know rebol has a first self and a second self? And when getting older, even got a third? see: pdp: func[dump][print mold/all do ?? dump] proof: context[ me: does[pdp[first self]] metoo: does[pdp[ second self]] methree: does[pdp[ third self]] me metoo methree ] --output: dump: [first self] [self me metoo methree] dump: [second self] [ #[object! [ me: #[function! [][pdp [first self]]] metoo: #[function! [][pdp [second self]]] methree: #[function! [][pdp [third self]]] ]] #[function! [][pdp [first self]]] #[function! [][pdp [second self]]] #[function! [][pdp [third self]]]] dump: [third self] [me: #[function! [][pdp [first self]]] metoo: #[function! [][pdp [second self]]] methree: #[function! [][pdp [third self]]]] (Exercise: figure out what these selfs are ;)
> > Anton. > >
<<quoted lines omitted: 12>>
> > > } > > > return ' %s %s,' % (name,dispatch[layout['type']])
i hope i get it: pdp: func [dump] [print mold/all do ?? dump] ; python can easily put kbLists.do_sql_radio() in a list. ; rebol likes to buck when getting functions from pathes. ; so i resort to using functions, more ugly, other way shown later. ; i want to stay close to python-code. do_sql: func [name layout /local dispatch] [ dispatch: reduce [ "radio" get in kb-lists 'do_sql_radio "text" get in kb-lists 'do_sql_text ; .. ] reduce [name select dispatch layout/type] ] kb-lists: context [ do_sql_radio: does [#radio] do_sql_text: does [#text] ; .. ] layo: [ type "radio" ; .. ] pdp [do_sql "name" layo] ; if the dispatchees are always from lb-lists, we can do do_sql: func [name layout /local dispatch word] [ dispatch: [ "radio" do_sql_radio "text" do_sql_text ; .. ] word: select dispatch layout/type reduce [name get in kb-list word] ] ; and if the words match to the names, like "radio" -> "do_sql_radio" do_sql: func [name layout /local dispatch word] [ word: to-word join "do_sql_" name reduce [name get in kb-list word] ] ; i guess python has similar ways to get from a string to a function, ; tell me ;)
> to elaborate: python automagically builds in internal dictionary > with the declared class members. Among other things, it allows > testing for validity of keyword values... > thus the 'for item in keys' test loop. >
See rebol-psychology above ;)
> > > # Example: using builtin _dict_ in class constructor > > > def __init__(self, url='', text='', **kw):
<<quoted lines omitted: 13>>
> > > for this class.' > >
clazz: context [ ; extra 'demo^init to allow super-call, we are pythonizing init: demo^init: func [kw /url url* /text text*] [ foreach item next first kw ; the "keys", skip 'self [ either in self item [ self/:item: get in kw item ; if it can be functions, else kw/:item is ok ] [ make error! rejoin [ "KeyError, " item " not a valid parameter for this class." ] ] ] self ] ; can be initialized immediate target: on-click: on-mouse-over: on-mouse-out: none ] demo: make clazz [] probe demo/init context [on-click: does["click"]] probe demo/init context [on-magic: does["magic"]] ; in this simple case we would use the inbuild stuff of course: demo: make clazz [ on-click: does["click"] ]
> -- > Tim Johnson <[tim--johnsons-web--com]> > http://www.alaska-internet-solutions.com > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. >
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler -- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted