> So this:
> 
>         my $class = "My::Class";
>         print("$class");
> 
> is:
> 
>         main::print("My::Class");
>
> ???

Not actually what I was suggesting. I'm going to have to go back to
Clear Examples School because somehow mine always end up confusing
issues inadvertently.

Remember, the techniques I suggest are only used if a local package
function is not found. So:

   package MyPackage;
   sub func { ... }

   func($object, @args);    # MyPackage::func($object, @args)


   package main;
   sub somefunc { ... }

   use MyPackage;
   my $mypkg = new MyPackage;   

   func($mypkg, @args);     # $mypkg->func(@args)

So, the first one will always be MyPackage::func, and the last one will
always be $object->func, because there is no main::func.

However, note that this only applies when you include the ","! If you
were to use the same exact example code from above, but explicitly use
the indirect object syntax:

   func($object @args);    # $object->func(@args)

Then this will always be forked because there is no comma between the
$object and @args.

I really hope I'm making sense. Looking at the RFC I realize it's
nowhere near clear enough because these two cases are really different.
So here are the two things I'm proposing, separated:

   1. Allow the ()'s to enclose the indirect object.
      Under this syntax, these two are equivalent:

          $q = new CGI (@args);
          $q = new(CGI @args);

      This requires an extra check for main::CGI first,
      and only if main::CGI(@args) cannot be called is
      CGI->new(@args) attempted.

   2. Allow a comma between the object and the args.
      With this, the above would become more flexible
      and these two would be equivalent:

          $q = new CGI (@args);
          $q = new(CGI, @args);

      Here, a check for main::new is made. If it doesn't
      exist, then CGI->new(@args) is attempted.

I think these are both doable. Hopefully this clarifies what I'm trying
to get at.

-Nate

Reply via email to