On Mon, Dec 19, 2016 at 11:05 PM, Jean-Philippe André <j...@videolan.org> wrote: > Hi, > > On 19 December 2016 at 21:10, Gustavo Sverzut Barbieri <barbi...@gmail.com> > 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.
argh... my bad with naming conventions, how should we call what I meant? Creators? Factories? > 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? that's a neat idea, to generate the macros with the new name if "implements" but if we do a macro that counts the number of parameters and if no class is given it would assume the default class (base), that's easier to use. -- Gustavo Sverzut Barbieri -------------------------------------- Mobile: +55 (16) 99354-9890 ------------------------------------------------------------------------------ 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 enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel