On Tue, 25 Jun 2013 13:47:40 +0200
Klaus Kaempf <[email protected]> wrote:

> * Josef Reidinger <[email protected]> [Jun 25. 2013 13:26]:
> > > 
> > > libyui-bindings has more complete examples
> > > (https://github.com/kkaempf/libyui-bindings/tree/master/swig/ruby/examples)
> > > which could help guiding a decision.
> > 
> > To be honest, I don't like this examples, it looks like old C gtk
> > where create every element is pain.
> 
> Lol - I don't like it either. It should just server as an example for
> the discussion.
> 
> > Compare this examples with elegance of
> > translated YCP code -
> > https://github.com/kobliha/yast-services-manager/blob/master/src/clients/services-manager.rb#L83
> 
> Thanks, thats helpful. I was missing this context.

It is locilka attempt to try ruby code from scratch and can nicely
demonstrate how will look translated code. Real translated code is
available only on installation DVDs and in source RPMs in
YaST:Head:ruby project. But from M4 you will be able to see it
everywhere :)

> 
> > 
> > I just want to get rid of annoying id, header and opt term. So after
> > your comments I propose to create shortcuts
> > Id, Opt and Header that creates such terms.
> 
> This is one (nice) way to solve this.
> 
>   ComboBox(
>     term(:id, IDs::DEFAULT_TARGET),
>     term(:opt, :notify),
>     _('Default System &Target'),
>     []
>   )
> 
> would change to
> 
>   ComboBox(
>     Id(IDs::DEFAULT_TARGET),
>     Opt(:notify),
>     _('Default System &Target'),
>     []
>   )
> 
> Another, probably more Ruby-like, is using hashes (as trailing
> arguments):
> 
>   ComboBox _('Default System &Target'), [], :id =>
> IDs::DEFAULT_TARGET, :opt => :notify,
> 

I agree that hash is more ruby way ( and I also consider it), but it is
problem for automatic translation. Ruby bindings use UI-bindings ( so
it use Y2 component system to call UI function ) and such functions
needs term. And I cannot automatic determine what is hash and what is
hash that should be translated to term.

Also challenge can be argument reordering as now order can be different
then using trailing hash.

I don't say that it is not possible, but it is currently out of scope
( as it include define special class heirarchy for UI and implement its
translation via ui-bindings or call it directly via ruby-bindings, but
there is risk, that there can be some bugs that is not in UI-bindings
). So improve UI creation in YaST is for different usefull project.

> [I removed the parantheses for ComboBox for readability]
> 
> (see http://mikepackdev.com/blog_posts/8-tuesday-tricks-splatting for
> example)
> 
> Comments ?
> 

I know this ruby feature and it is really nice, but not much usable
when we need to communicate via Y2 component system. Also there is
now challenge with default parameters, but I plan to fix it as ruby1.9
can say number of possible arguments and I can create overloaded method.

So I implement first solution.

Josef
-- 
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]

Reply via email to