On Mon, 6 Aug 2001, Marc wrote:
> On Mon, Aug 06, 2001 at 01:21:12PM +0300, Ilmari Karonen <[EMAIL PROTECTED]> wrote:
> > Shouldn't that rather be
> >
> > use constant NOTHING => ();
>
> yes, I noted that as well (but for some reason I forgot to reply to the
> list). This one indeed works, until you try to do this:
>
> use constant NOTHING => (),
> FIVE => 5;
Actually, that isn't even supposed to work, and it wouldn't work even if
NOTHING had a scalar value.
use constant FOO => 1, BAR => 2;
is precisely equivalent to
use constant FOO => (1, 'BAR', 2);
and defines FOO as a three-element list constant.
I suppose what you meant was
use constant {
NOTHING => (),
FIVE => 5,
};
which does exhibit the bug. The fact that only scalar constants may be
defined using this syntax is an obvious, known and now also documented
limitation of constant.pm, though the patch documenting this is so far
only included in bleeding-edge development versions of perl.
> Since () is not a constant (it really is _nothing_ ;) I would not be
> surprised if constant.pm would turn it into undef in a future version or
> (like currently) treats it as nonexistant.
It won't. This, in fact, has been documented even before the patch
mentioned above. () is an empty list, and the fact that an empty list
constant evaluates to undef in *scalar* context is an explicit feature
of constant.pm.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"By blow up, I mean that you can separate a massive body into two or more
parts that proceed in different directions at a high rate of speed. If
you prefer the technical term, you can say that you can change its
quadrapole moment." -- pervect in rec.arts.sf.science