Hi,

On 19 December 2016 at 21:10, Gustavo Sverzut Barbieri <[email protected]>
wrote:

> Hi all,
>
> In Efl.Net I've created couple of "constructors" functions to help the
> user with common tasks, such as:
>

Hmm. Sorry to be pedantic, but you've created @class functions, not
constructor functions. :)

    src/lib/ecore_con/efl_net_ip_address.eo:
>
>        - create(port, address)
>        - create_sockaddr(sockaddr)
>        - parse(string)
>        - resolve(string, family, flags) (returns a promise)
>
> In many languages that's easy to use:
>
>     efl.net.ip_address.create(1234, "127.0.0.1")
>
> But in C it's a bitch:
>
>    efl_net_ip_address_create(EFL_NET_IP_ADDRESS_CLASS, 1234, "127.0.0.1");
>

EO constructors would instead be used as follows:
efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, efl_net_ip_address_set(1234,
"127.0.0.1"));

Not saying it looks any better, really. But that's what constructors are,
in EO.


While these are nice to be "class methods" since one could get these
> to work with subclasses, they are often used with the original class.
> Then my request is to either to introduce a "staticmethod" OR to use
> some macro trick to count the number of parameters and pass the class
> automatically when omitted or generate 2 functions, one with class and
> another without (one could be an actual function, while the other just
> a macro).
>
> End goal is to make these look more like:
>
>     efl_net_ip_address_create(1234, "127.0.0.1");


A macro could be nice. We still need @class functions to work with other
classes than the one that declares the method. Each class can then have its
own implementation of the common @class function. Should all sub
implementations also provide a macro, then?

Best regards,

-- 
Jean-Philippe André
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to