On Fri, Oct 27, 2017 at 12:42 AM, Jean-Philippe André <j...@videolan.org>
wrote:

> 2017-10-27 11:12 GMT+09:00 Amitesh Singh <singh.amit...@gmail.com>:
>
> > Hello,
> >
> >
> > On Thu, Oct 26, 2017 at 9:30 PM, Gustavo Sverzut Barbieri <
> > barbi...@gmail.com> wrote:
> >
> > > On Thu, Oct 26, 2017 at 10:12 AM, Amitesh Singh <
> amitesh...@samsung.com>
> > > wrote:
> > >
> > > thanks for the improvement, but one hint I said before went unnoticed
> > > and would save great deal of this implementation:
> > >
> > >
> > > > +typedef struct
> > > > +{
> > > > +   const char *template;
> > > > +} Efl_Ui_Format_Data;
> > >
> > > this is already stored in the object, due format_string_set... that's
> > > why I'm saying that you should pass it to the callback, so there is no
> > > need to store it again, providing a free_cb to release that.
> > >
> > >
> > >
> > > > +_default_format_cb(void *data, Eina_Strbuf *str, const Eina_Value
> > value)
> > >
> > > here you should pass: str, value AND template :-)
> > >
> > >
> > I don't think there is a need to pass tempate here since its least useful
> > to user and its a burden for anyone to have both strbuf and template
> > string.
> > We got another API for passing string template.
> >
>
> Hmm I agree with Amitesh here.
> If the template is given as well then the user cb is mostly useless, as the
> default implementation would take care of doing the sprintf.
> All that can then be done is prepend or append strings, at best.
>
> I wonder if that wouldn't lead to more mistakes as we would then assume
> what the format string is (eg. print  a double eina_value with "%i units"
> for instance).
>


well, I see very rare cases to pass a cb. But since we pass it, then just
fwd to it the template string, likely it's going to be used.

Say format cb that applies translations (gettext, dgettext)... other
example is single x plural x none, like:

  - template if value > 0
  - "no entries" if 0.



-- 
Gustavo Sverzut Barbieri
--------------------------------------
Mobile: +55 (16) 99354-9890
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to