[REBOL] Re: Binding problem with 'do
From: lmecir::mbox::vol::cz at: 31-Jul-2005 23:24
Tim Johnson napsal(a):
>* Ladislav Mecir <[lmecir--mbox--vol--cz]> [050731 02:18]:
>
>>> code: load rejoin["append output do-" type " name layout"]
>>> ?? code ;; see code "dump" below
>>> do code
>>> ]
>>> ]
>>>
>>>
>>>
>>>
>>...snip...
>>
>>that load rejoin [...] is a "beginner's gotcha" described in the doc. It
>>brings more problems that it can solve. Don't use "command strings" when
>>you don't have to, always use blocks - it is faster, safer and simpler.
>>What about this one?
>>
>>
>
> Hi Ladislav:
>
> Boy am I behind in docs! What I have doesn't have any gotchas.
> Can you point me to those docs?
>
See e.g. http://www.rebol.com/docs/core23/rebolcore-4.html#section-4.6:
Unless it is necessary, evaluating strings is not generally a good
practice...
>>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.