Hi, guys.
The next issue that I found with autobox is that all your hashes and arrays must be references (despite what the POD docs seem to indicate).
Yes, the receiver must be a scalar i.e. (by default) a string, number or reference. If there's somewhere in the docs that makes this unclear or ambiguous, please let me know and I'll fix it. Note that there is a module by Scott Walters, Perl6::Contexts, that allows methods to be called on plain (i.e. non-reference) hashes and arrays.
And then the last problem I have with it is that the pragma is not lexically scoped.
I apologise if I gave that impression. It's always been lexically scoped and works independently of the lexical pragma. There are a bunch of tests that verify its "lexical correctness" in the test suite.

scope1.pl:

01: $| = 1; 02: 03: sub SCALAR::uc { uc $_[0] } 04: 05: { 06: use autobox; 07: print "hello, world!"->uc; 08: } 09: 10: print "hello, world!"->uc;

> perl -l scope1.pl

HELLO, WORLD!

Can't locate object method "uc" via package "hello, world!" (perhaps you forgot to load "hello, world!"?) at scope1.pl line 10.

scope2.pl:
01: $| = 1; 02: 03: sub SCALAR::uc { uc $_[0] } 04: sub test { $_[0]->uc } 05: 06: { 07: use autobox; 08: print "hello, world!"->uc; 09: test("hello, world!"); 10: }

> perl -l scope2.pl

HELLO, WORLD!

Can't locate object method "uc" via package "hello, world!" (perhaps you forgot to load "hello, world!"?) at scope2.pl line 4.

scope3.pl:
01: $| = 1; 02: 03: sub SCALAR::uc { uc $_[0] } 04: 05: { 06: use autobox; 07: print "hello, world!"->uc; 08: 09: { 10: no autobox; 11: print "hello, world!"->uc; 12: } 13: }

> perl -l scope3.pl

HELLO, WORLD!

Can't locate object method "uc" via package "hello, world!" (perhaps you forgot to load "hello, world!"?) at scope3.pl line 11.

At any rate, don't trust my poorly and hastily written emails; trust my poorly and hastily written docs and tests :-)

chocolateboy


In reply to Re^4: Using CORE:: with autobox by chocolateboy
in thread Using CORE:: with autobox by bennymack

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.