Ticket #1472 (closed cage: invalid)

Opened 5 years ago

Last modified 4 years ago

Namespace.get_pointer_keyed is TOTAL KLUDGE

Reported by: whiteknight Owned by:
Priority: normal Milestone:
Component: none Version: 2.1.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

Namespace PMC contains this gem of a comment:

=item C<void *get_pointer_keyed(PMC *key)>

Return the given namespace item or PMCNULL. If the named item is either
a NameSpace or a var, the var is returned.

TOTAL KLUDGE.  ON THE CHOPPING BLOCK.

Why is it a kludge, and why is it on the chopping block? If it's really intended to disappear, it should be listed in DEPRECATED.pod. We should also figure where it is used, if anywhere, and evaluate if it's still needed.

Change History

Changed 5 years ago by jkeenan

get_pointer_keyed() is invoked or discussed in quite a few files:

$ fns . | xargs grep -n get_pointer_keyed      
./src/pmc/namespace.pmc:562:=item C<void *get_pointer_keyed_str(STRING *key)>
./src/pmc/namespace.pmc:564:=item C<void *get_pointer_keyed(PMC *key)>
./src/pmc/namespace.pmc:576:    VTABLE void *get_pointer_keyed_str(STRING *key) {
./src/pmc/namespace.pmc:590:    VTABLE void *get_pointer_keyed(PMC *key) {
./src/pmc/namespace.pmc:598:                return SELF.get_pointer_keyed_str(VTABLE_get_string(INTERP, key));
./src/pmc/namespace.pmc:606:                        return VTABLE_get_pointer_keyed_str(INTERP, ns, part);
./src/pmc/namespace.pmc:622:                        return VTABLE_get_pointer_keyed_str(INTERP, ns, part);
./src/pmc/namespace.pmc:633:                    "Invalid namespace key of type '%S' in get_pointer_keyed",
./src/vtable.tbl:58:void* get_pointer_keyed(PMC* key)
./src/vtable.tbl:59:void* get_pointer_keyed_int(INTVAL key)
./src/vtable.tbl:60:void* get_pointer_keyed_str(STRING* key)
./src/oo.c:590:    PMC * const value = (PMC *)VTABLE_get_pointer_keyed(interp, interp->class_hash, name);
./src/global.c:452:    return (PMC *)VTABLE_get_pointer_keyed_str(interp, ns, globalname);
./src/global.c:511:         * distinguishes 'get_pmc_keyed' from 'get_pointer_keyed';
./src/global.c:514:        res = (PMC *)VTABLE_get_pointer_keyed_str(interp, ns, globalname);
./src/pmc.c:779:            (PMC *)VTABLE_get_pointer_keyed_str(interp, classname_hash, name);
./src/pmc.c:810:    PMC * const item = (PMC *)VTABLE_get_pointer_keyed(interp, classname_hash, name);
./docs/pdds/pdd17_pmc.pod:823:=item get_pointer_keyed
./docs/pdds/pdd17_pmc.pod:825:  void* get_pointer_keyed(INTERP, PMC *self, PMC *key)
./docs/pdds/pdd17_pmc.pod:826:  void* get_pointer_keyed_int(INTERP, PMC *self, INTVAL key)
./docs/pdds/pdd17_pmc.pod:827:  void* get_pointer_keyed_str(INTERP, PMC *self, STRING *key)
./docs/embed.pod:1146:=item C<Parrot_PMC_get_pointer_keyed>
./docs/embed.pod:1148:=item C<Parrot_PMC_get_pointer_keyed_int>
./docs/embed.pod:1150:=item C<Parrot_PMC_get_pointer_keyed_str>
./tools/dev/vtablize.pl:68:s/^(\s*)(void\s+\*get_pointer_keyed\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/;
./tools/dev/vtablize.pl:69:s/^(\s*)(void\s+\*get_pointer_keyed_int\(INTVAL\s+\w*\)\s+{)/$1VTABLE $2/;
./tools/dev/vtablize.pl:70:s/^(\s*)(void\s+\*get_pointer_keyed_str\(STRING\s+\*\w*\)\s+{)/$1VTABLE $2/;

So, while it may well be a kludge, it does not appear to be an obvious candidate for deprecation.

Thank you very much.

kid51

Changed 4 years ago by cotto

  • status changed from new to closed
  • resolution set to invalid

Kludges don't make for good tickets. Some of the namespace code is definitely ugly and well-deserving of a refactor, but without a plan it's just another wart. I'd encourage the addition of such code to ItsABughunt. I'm closing this ticket as invalid.

Note: See TracTickets for help on using tickets.