in reply to Import constants as scalar instead of bareword sub

Exporter already supports this. The problem is that this can allow the modification of the constant in a global way.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: Import constants as scalar instead of bareword sub

Replies are listed 'Best First'.
Re^2: Import constants as scalar instead of bareword sub
by powerman (Friar) on Nov 02, 2005 at 18:58 UTC
    What Exporter supports? Autocopying function to scalar? Can you give me example how I can get $O_NONBLOCK using use Fcntl qw(some dirty Exporter magic);?

    About modification of constants... yeah, you right. But I suppose this can be solved without performance loss by marking that scalar read-only in SV..? Anyway, I prefer read-write scalars to bareword subs. And if I'll see in somebody's code: $EINTR=123; than I will fire that guy immediatelly! :)

      Do you also disallow soft references? ${$foo} = 123; is just as dangerous. As for autocopying a function to a scalar, that's not hard to do with a generalized import function. Learn a little symbol table magic - it's good for the soul. :-)

      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
        Hm. This is Meditation, AFAIK, not Seekers of Perl Wisdom. I don't ask "is it possible to do some dark magic with symbol table using some generalized import()", I can do this without problems, as least I hope so. :) I ask "is it has sense to go this way"...