On 10/29/2014 03:07 PM, Morse, Richard E.,MGH wrote:
On Oct 29, 2014, at 2:56 PM, Uri Guttman <[email protected]> wrote:
hi ricky,
i am somewhat confused as to your goal. you want each sub to use a common %map?
why not have them access it directly from the base package?
Hi! There are actually three different package variables that contain different
information about how to handle translating things into that language. What I'm
trying to do is be able to create packages (not classes) that handle certain
kinds of special cases where the different languages do things differently.
Mostly, everything is the same, but there are a few odd cases where something
is radically different, and I have to write a function in a completely
different way. So the problem is almost exactly the opposite -- I want the same
function to use a different %map (%strings, %langfiles, %collators) depending
on which package it is in.
how can you have the same function in different packages? do you mean a
base version but it accesses a different map depending on where it is
called?
i smell an XY problem here. you are attempting to do this with package
stuff which is just a fancy hash table with special side effects. why
not just make a pure perl hash that has all you need. then you can
decide what to access by simple keys as arguments.
so something like this:
{
Eng => {
strings => {
foo => sub {},
}
}
}
then you can access the language, the feature and the special sub (if it
exists). you fall back to a base level of subs (could be a 'BASE' key as
the lang level) if no sub exists for that lang. when you call a sub to
do work you pass in the lang key being used. then the subs can decide to
access by that key or another in their code.
this is all in one nice table that is easy to see and modify. putting
all that into separate but very related modules is more work and pain
IMO. you just need a combined data tree and dispatch table.
thanx,
uri
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm