in reply to Re^7: XS: use module into package
in thread XS: use module into package

I'm just trying to replicate use as it is internally for perl, so I can make it work with things like use feature 'say', which don't work with an eval qq{package $callerpkg; use feature 'say'}, but do if I use a goto &feature::import.

Nothing against eval, I just think that the behaviour is inconsistent for lexical "uses".

Replies are listed 'Best First'.
Re^9: XS: use module into package
by ikegami (Patriarch) on Jun 14, 2011 at 06:57 UTC

    I'm just trying to replicate use as it is internally for perl

    use is a compiler directive to immediately do a require and (possibly) import.

    To replicate that, your code would need to be parsing Perl code. Your statement makes no sense.

    but do if I use a goto &feature::import.

    «goto &feature::import» has no resemblance to «eval 'package Package; use Module;'» and has nothing to do with «use»!!!

    This is getting silly. You have yet to communicate what problem you are trying to solve. When you figure it out, you should start a new thread.

    Nothing against eval, I just think that the behaviour is inconsistent for lexical "uses".

    What do you think use does with the code it loads? It evals it.