Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: how get stash name of SV?

by dave_the_m (Monsignor)
on Oct 11, 2019 at 10:36 UTC ( #11107338=note: print w/replies, xml ) Need Help??


in reply to how to get stash name of SV?

The SvSTASH() field of an SV typically indicates the class that an SV was blessed into. The field is only physically present if the SV is of type >= SVt_PVMG, and only contains a valid/useful value under certain circumstances (such as SvOBJECT(sv) being true).

It isn't a general field of an SV indicating what stash a package variable is located in.

Dave.

Replies are listed 'Best First'.
Re^2: how get stash name of SV?
by xiaoyafeng (Chaplain) on Oct 12, 2019 at 07:19 UTC
    So If I understand correctly, the name of SvSTASH is a little bit misleading. it should be SvCLASS or not SvSTASH?




    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

      So If I understand correctly, the name of SvSTASH is a little bit misleading. it should be SvCLASS or not SvSTASH
      In an ideal world, perhaps yes.

      Dave.

      I suspect that the choice of name for that field is related to how Perl 5 objects are implemented internally: an object uses some package (internally represented as a "stash", which is a hash storing typeglobs) as its vtable. Perl does not really have classes as distinct objects, so the name SvSTASH doubtless made perfect sense when the feature was added to what became Perl 5.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11107338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2019-12-10 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?