Grokbase
x

Re: User-defined case mappings; use static variable in Perl?

View PostFlat  Thread  Threaded | < Prev - Next >
Rafael Garcia-Suarez Re: User-defined case mappings; use static variable in Perl?
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2009/11/15 karl williamson <public@khwilliamson.com>:
> I have been thinking somewhat of how to implement this. =A0The problem is=
we
> don't want to slow down things for this very rare (maybe non-existent) us=
e.
> =A0Since this feature is based on global subroutines, I would think one c=
ould
> store in a static variable if the existence of such a subroutine has been
> looked for or not. =A0Then it could be structured so that the normal flow=
had
> just one test added to check this static. =A0For example, initialize the
> static to 0 for not-looked at yet; set it to something else on the first
> time the case function is called, say 1 if found no routine; and anything
> else if found a routine. =A0There would have to be one variable for each =
of
> lc, uc, and ucfirst (since lcfirst uses the same case definitions as lc).
>
> Now, I'm not very familiar with Perl internals, so I'm asking. =A0I would
> think we would not want to normally use statics just because of lexical
> scoping and threads. =A0But in this case, there is no lexical scoping, an=
d the
> user-defined subroutines would apply to all threads. =A0So would a static
> variable be an ok thing to use here?

No : because of embedding. (Perl interpreter(s) might be embedded in
other programs, such as the vim editor for example)

The correct way to add a global variable is to add it to perlvars.h;
and to add a per-interpreter variable, you have to add it to
intrpvar.h. I think that in this case you want intrpvar.h.

Thread : Re: PATCH: Add code to solve the casing portion of the "Unicode bug"
1)
Rafael Garcia-Suarez 2009/11/13 karl williamson <public@khwilliamson.com>: n Thanks, applied as...
2)
karl williamson I can imagine them being used for Turkish and Azeri, where the standard is problematic, and the...
3)
Rafael Garcia-Suarez 2009/11/15 karl williamson <public@khwilliamson.com>: we e. ould had of d the No : because of...
4)
karl williamson I still like the idea of the legacy pragma. What I was thinking was, though, to remove this...
5)
Nicholas Clark I've not read the patch. I can comment on this: They're not wrong. The calls SvPV_force_nomg() and...
6)
karl williamson Ah! I figured that the calls could flip the flag, but the comment still doesn't make sense to me,...
spacer
View PostFlat  Thread  Threaded | < Prev - Next >