in reply to Re^5: RFC : Pragma vs. Module
in thread RFC : Pragma vs. Module

I agree. Personally, I never use the sub INIT {} form, I always do the block form INIT {} it makes them look (a little) more distinct in the code.

But how do you go about actually calling the CHECK and INIT blocks?

I would likely move the code in INIT out into another sub, and have INIT call that (allowing it to fail in mod_perl since it only produces a warning, although this would not be okay if you had set the warnings to be fatal). Then check for the mod_perl env, and push a handler that calls the sub-formerly-known-as-INIT. This is of course a simple and untested approach, but it certainly a surmountable problem.

-stvn

Replies are listed 'Best First'.
Re^7: RFC : Pragma vs. Module
by Aristotle (Chancellor) on Mar 15, 2004 at 19:54 UTC
    But rather than making vanilla INIT work under mod_perl you're then introducing new semantics. Which mod_perl already has: the pseudohandlers you pointed out before.

    Makeshifts last the longest.

      I am in no way capable of making vanilla INIT work in mod_perl as I am not a C programmer, nor would I have any clue as to how to do that even if i was one. :-) So my only option (as i see it) to make Class::Trait work under mod_perl would be to do something like i described. Although, to be honest, I think I am going to look into avoiding using INIT altogether in Class::Trait.

      -stvn