Re: GSoC C backend report 3
William S Fulton <wsf <at> fultondesigns.co.uk>
2012-07-24 06:03:59 GMT
On 14/06/12 23:00, Leif Middelschulte wrote:
> Am Mittwoch, 13. Juni 2012 um 01:01 schrieb Vadim Zeitlin:
> > On Tue, 12 Jun 2012 02:56:28 +0200 Leif Middelschulte
> > <leif.middelschulte <at> gmail.com <mailto:leif.middelschulte <at> gmail.com>>
> > wrote:
> >
> > LM> What it used to be like:
> > LM> - lots of "(Cmp(Getattr(n, "foo"), "1") == 0)"
> > ...
> > LM> What it's now like:
> > LM> - Used macros like IS_SET_TO_ONE(n, "foo")
> >
> > Hello,
> >
> > I'm really, really far from certain that this is an improvement. The old
> > version might have been a bit verbose but it's perfectly clear while the
> > new one is less so.
> > Also, and arguably more importantly, the former version
> > is used everywhere in SWIG code base while the new one is only used in C
> > module making it inconsistent with everything else.
> >
> > And if I could live with IS_SET_TO_ONE, I really think you should remove
> > the IS_EQUAL(x,y) macro because using Cmp(x,y)==0 is almost as short
> > but is
> > more clear and standard.
> >
> > Finally, to close this topic, this is C++, not C, so you should define
> > inline functions and not macros if you think they're worth having. But I
> > really think they're not anyhow.
> Hi,
>
> I think you're right about this. Actually I think it's very bad that I
> "had to" put them into the module code.
> But you have to see the context here. Let me give you an example of how
> code looked like:
>
> if (!is_global && storage && Cmp(storage, "static") != 0) {
> if ((Cmp(Getattr(n, "ismember"), "1") == 0) &&
> (Cmp(nodeType(n), "constructor") != 0)) {
>
> vs.:
>
> if (!is_global && storage && !IS_EQUAL(storage, "static")) {
> if (IS_SET_TO_ONE(n, "ismember") &&
> !IS_EQUAL(nodeType(n), "constructor")) {
>
> I think that the macros aren't as good as they could be. E.g. embedding
> the nodeType() call is bad. Iirc it's another reoccuring pattern, thus
> get a macro/function of it's own.
> Imho there should be a globally known set of macros or inline functions
> used accross swig for such common patterns.
> I think doing so will reduce the inconsitencies in style like "!Cmp()"
> vs. "Cmp() == 0".
> Anyway, I just wanted to explain myself and will go on with the Cmp()==0
> and Cmp()!=0 style and remove the macros eventually.
Sorry for stepping in so late, but there is the Equal function you could
use for string comparison. Also for attributes in a node which are
flags, use GetFlag(n, "ismember").
William
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/