[Python-checkins] r45279 - in python/trunk: Parser/pgenmain.c Python/compile.c Python/future.c Python/pyarena.c Python/pystate.c

Anthony Baxter anthony at interlink.com.au
Tue Apr 11 14:26:16 CEST 2006


On Tuesday 11 April 2006 22:21, Jeremy Hylton wrote:
> > more low-hanging fruit. Not entirely happy with the two new VISIT
> > macros in compile.c, but I couldn't see a better approach.
>
> Could you provide more descriptive log messages?  I can't fathom
> what kind of low-hanging fruit you are talking about.  I'm guessing
> that you are dealing with warnings on some compiler, but I don't
> know which one or why we didn't see them before.

Ok. In this case, it's making the code compile with C++ compilers.

I'll edit the log messages.

> As for the new visit macros, the second argument to VISIT is the
> type of the sequence elements that are being iterated over.  You
> should be able to generate a cast from that without passing a
> separate cast token.  I can't think of a case where TYPE did not
> imply CAST.
>
> -       VISIT_SEQ(c, stmt, s->v.TryFinally.finalbody);
> +       VISIT_SEQ_WITH_CAST(c, stmt, s->v.TryFinally.finalbody,
> stmt_ty);
>
> +#define VISIT_SEQ_WITH_CAST(C, TYPE, SEQ, CAST) { \
> +       int _i; \
> +       asdl_seq *seq = (SEQ); /* avoid variable capture */ \
> +       for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \
> +               TYPE ## _ty elt = (CAST)asdl_seq_GET(seq, _i); \
>
>                                             (##_ty) instead of
> CAST?

Hm. That seems like a workable approach. Will give it a go.


-- 
Anthony Baxter     <anthony at interlink.com.au>
It's never too late to have a happy childhood.


More information about the Python-checkins mailing list