RE: WITH_THR and WITH_THX

[email protected] ("Jan Dubois")
Newsgroups perl.perl5.porters
Organization ActiveState Software Inc
Message-ID <[email protected]>
On Wed, 16 Jun 2010, Nicholas Clark wrote:
> 
> There are currently exactly two uses of WITH_THR/WITH_THX in core.
> 
> #define WITH_THX(s) STMT_START { dTHX; s; } STMT_END
> #define WITH_THR(s) WITH_THX(s)
> 
> As far as I can tell, neither is needed. If I do the following, it still
> builds and passes all tests:


[...]

>  #define DEBUG_CX(action)						\
> -    DEBUG_l(WITH_THX(							\
> +    DEBUG_l(								\

[...]

>  #define DEBUG_SCOPE(where) \
> -    DEBUG_l(WITH_THR( \
> +    DEBUG_l( \

[...]
 
> Is there a reason why they're actually needed? I can't work it out for sure,
> and I didn't really want to remove something on the basis of "works on my
> machine" without understanding it.

The only reason I can come up with is that this makes DEBUG_CX() and DEBUG_SCOPE()
work even if you use them in code that doesn't already have a visible aTHX
(not sure if that can reasonably happen, but I assume it was the case in the
past; otherwise nobody would have bothered adding the WITH_xxx() wrappers).

It looks like DEBUG_CX and DEBUG_SCOPE() are currently only used when aTHX
is already defined, so the additional WITH_THX() and WITH_THR() calls seem
redundant now.

Cheers,
-Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.