* Anton Rolls <[EMAIL PROTECTED]> [050801 01:38]:
> 
> Hi Tim,
> 
> Your code below seems to be generating code using a macro.
> It seems extremely unwieldy to me and needs a clever
> bit of rebol to shrink it to its essence.
> 
> What are the changing parts (what value and type are they) ?
> 
> It looks to me like the changing parts are:
> 
>       - widget style 
>       - widget feel
> 
> where the feel is just used to detect different key presses (?)
> 
> I would love to know the intention of your code so we
> can refactor it.
 
  <grin> We just did. We refactored it in rebol. Yes. python
         is cumbersome, but it scales well, and some
         customers want it. Even the code below could be
         factored more. FI: dispatch should be a method
         of kblists...
         
         tim

> Anton.
> 
> > # Example: explicit
> >  def do_sql(name,layout):
> >       dispatch = {
> >           'radio':kbLists.do_sql_radio(),
> >           'text':kbLists.do_sql_text(),
> >           'textarea':kbLists.do_sql_textarea(),
> >           'decimal':kbLists.do_sql_decimal(),
> >           'uinteger':kbLists.do_sql_uinteger(),
> >           'select':kbLists.do_sql_select(),
> >           'date':kbLists.do_sql_date(),
> >           'checkbox':kbLists.do_sql_checkbox(),
> >           'password':kbLists.do_sql_text(),
> >           }
> >       return '  %s %s,' % (name,dispatch[layout['type']])

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.

> > # Example: using builtin _dict_ in class constructor      
> >     def __init__(self, url='', text='', **kw):
> >         self.target = None
> >         self.onClick = None
> >         self.onMouseOver = None
> >         self.onMouseOut = None
> >         self.url = url
> >         self.text = text
> >         # target ... text constitutue self.__dict__ when they are
> >         # preceded by 'self.'
> >         for item in kw.keys():
> >             if self.__dict__.has_key(item):
> >                 self.__dict__[item] = kw[item]
> >             else:
> >                 raise KeyError, `item`+' not a valid parameter 
> > for this class.'
> 
> -- 
> To unsubscribe from the list, just send an email to 
> lists at rebol.com with unsubscribe as the subject.

-- 
Tim Johnson <[EMAIL PROTECTED]>
      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.

Reply via email to