perl-unicode

Re: Unicode aware module

1999-04-23 12:35:13
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 have not thought this out, but maybe

sub abc : utf8 {
}

sub abc : ascii {
}

sub abc {
}

could be allowed such that the utf8 sub is only called when utf8 is in
effect, the ascii (or byte whatever) is called when we are in that mode
(which currently is when we are not in utf8 mode) and the last would be
called for any other utf8-like pragma, say if we had utf16 in effect.

Now we cannot store these in the symbol table as we cannot have multiple
subs by the same name, but we could mangle the name, eg

  sub abc : utf8    => abc__utf8 or __utf8_abc

and have a flag on the abc sub to say we have such subs. Then when the
compiler is doing a lookup it would first lookup abc, if that had the
hint bit set it would look for the sub for the current mode. If that
cannot be found it would use abc

But is this a mis-use of the : notation ?

-- 
Graham Barr <gbarr(_at_)ti(_dot_)com>
Ah! Don't say that you agree with me. When People agree with me I always
feel that I must be wrong.      -- Oscar Wilde

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