Tim Johnson napsal(a):

>* Ladislav Mecir <[EMAIL PROTECTED]> [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.

>>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.

Reply via email to