in reply to Re: overloading core function and non-existing operator
in thread overloading core function and non-existing operator

Just want to let my mind fly freely for a moment, with Perl and yet not ...

Say it is more consistent, and main scope itself is also a package just like any other package. Will that help to make ++ overloadable in main? My answer to myself was probably no, as the other side of this issue, probably a more important one is not about scope, but about "native data type". Even if you can overload with main scope, it makes sense not to let one overload operators against native data type, for example scalar.

  • Comment on Re^2: overloading core function and non-existing operator

Replies are listed 'Best First'.
Re^3: overloading core function and non-existing operator (...constants)
by tye (Sage) on Aug 08, 2005 at 06:04 UTC
Re^3: overloading core function and non-existing operator
by tinita (Parson) on Aug 08, 2005 at 09:54 UTC
    and main scope itself is also a package just like any other package. Will that help to make ++ overloadable in main?

    sure, if you see it that way... you just have to bless your variable, just like you did with your Number-package.

    use overload ...; my $n = bless {number => 23}, "main"; print $n >> 2;
    i think that's not what you want, just wanted to make clear that it's not a problem of the package name but that you must have a blessed object.