[REBOL] Re: Binding problem with 'do
From: tim:johnsons-web at: 31-Jul-2005 14:05
* Ladislav Mecir <[lmecir--mbox--vol--cz]> [050731 13:39]:
> See e.g. http://www.rebol.com/docs/core23/rebolcore-4.html#section-4.6:
Thanks! Keeping that by my bedside .....
> "Unless it is necessary, evaluating strings is not generally a good
I do bend the rules when I do something quick-and-dirty not meant
for public access and is performance is not an issue.
But then one can forget and leave in tacky code.
> >>type-handler: make object! [
> >> button: func [name layout] [print "this is do-button" 'do-button]
> >> checkbox: func [name layout] [print "this is do-checkbox" 'do-checkbox]
> >> time: func [name layout] [print "this is do-time" 'do-time]
> >> hidden: func [name layout] [print "this is do-hidden" 'do-hidden]
> >> radio: func [name layout] [print "this is do-radio" 'do-radio]
> > That's almost pythonistic in it's engineering (from me that's a
> > complement) :-). However, if I understand you correctly, it would
> > be as large and repetitive as the original switch.
> That may be a misunderstanding. As far as I understand your code it uses
> a set of functions called DO-BUTTON, DO-CHECKBOX, DO-TIME, DO-HIDDEN,
> DO-RADIO, but you didn't "provide" them. So I just wrote a "bogus"
> implementation of the above mentioned functions to have a more complete
> example, that is all.
> >>output: copy 
> >>foreach plist glbs/plists [
> >> foreach [name layout] plist [
> >> type: in type-handler to word! select layout "type"
> >> append output do type name layout
> > I would upon recoding, place all type handlers in a context with
> > the same name as the type.
> > ;Then replace
> > append output do type name layout
> > ;; with
> > append output type-handler/:type name layout
> > Or even create a 'name and 'layout member for the type-handler
> > context - to cut down on the interface specs for the methods.
> > For the time being, the solution was to use
> > do compose[append output (to-word join "do-" type) name layout]]
> > ;; but a formal type-handler context is more professional, methinks
> > Regards
> > tim
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
Tim Johnson <[tim--johnsons-web--com]>