perl-unicode

Re: Unicode aware module

1999-04-23 12:55:07
On Fri, 23 Apr 1999 14:00:10 CDT, Graham Barr wrote:
On Fri, Apr 23, 1999 at 11:44:17AM -0700, Gurusamy Sarathy wrote:
On Fri, 23 Apr 1999 11:30:27 PDT, Dick Hardt wrote:
Oh.... Hmmm....  So Graham's point about wanting to know the context of the
caller is important then.

For example, the Win32::* modules can be updated so that depending on
whether utf8 was set or not, W or A calls to the OS would be made. To do
this, the subs will need to know the context of the caller.

wantutf8() should be easy to write as an XSUB.  Here's an untested version:

It seems a shame to put something done at runtime between two things
which are determined at compile time. (ie the wrapper sub I posted)

I wonder if it would be possible to tell the compiler that there
are multiple implementations of a sub and have it pick the right
one. Sort of like what Dick described.

I think of this as an optimization that is best handled by the
compiler.  Leaving it to the programmer to suggest what could be
inferred by the compiler seems like "too much work".  Note that
the same situation applies to wantarray() as well.  Given:

       sub foo {
           if (wantarray) {
              ...
           }
           else {
              ...
           }
       }

the compiler could generate these foo() variants: one with both
branches determined at runtime (as written), another with only the
wantarray branch, and a third with the "else" branch.

A powerful idea that I've been pondering is to ability to mark
user-defined subs/xsubs as callable at compile-time (a la BEGIN{}).
This effectively makes their return values known at compile-time,
when various optimizations can use that information.

When you bring in "inlined" subs/xsubs, the picture grows
increasingly complete.


Sarathy
gsar(_at_)activestate(_dot_)com

<Prev in Thread] Current Thread [Next in Thread>