Your SlideShare is downloading. ×
0
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Global destruction (in 5 minutes)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Global destruction (in 5 minutes)

288

Published on

Limitations of perl global destruction feature. …

Limitations of perl global destruction feature.
Not all, just some. Not talking about order or problems in DESTROY methods.

Published in: Engineering, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
288
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Global Destruction Thursday, May 8, 14
  • 2. in 5 minutes There’s another talk: Global Destruction in 20 Minutes Thursday, May 8, 14
  • 3. What is global destruction? Thursday, May 8, 14
  • 4. What is global destruction? • Perl has a couple of run-time phases: BEGIN, CHECK, UNITCHECK, INIT, runloop, END, DESTRUCT • perldoc perlmod Thursday, May 8, 14
  • 5. What is global destruction? • BEGIN, CHECK, UNITCHECK, INIT, runloop, END, DESTRUCT • DESTRUCT cannot be called by DESTRUCT {} blocks. Thursday, May 8, 14
  • 6. What is global destruction? • BEGIN, CHECK, UNITCHECK, INIT, runloop, END, DESTRUCT • DESTRUCT cannot be called by DESTRUCT {} blocks. • the runloop neither Thursday, May 8, 14
  • 7. DESTRUCT • DESTRUCT is executed after PerlIO_destruct and before PerlIO_clean • DESTRUCT calls DESTROY methods on all objects which do have a DESTROY method (sv_clean_obj) Thursday, May 8, 14
  • 8. package FINALE; { $ref3 = bless ["ok - package destruction"]; my $ref2 = bless ["ok - lexical destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } DEMO t/testc.sh -A -O3 -k 197 DESTRUCT Thursday, May 8, 14
  • 9. DESTRUCT • Beware! Our current perlcc compiler does not do global destruction. • 2nd warning: our variables behave like globals! Use only my, not our Thursday, May 8, 14
  • 10. package FINALE; { $ref3 = bless ["ok - package destructionn"]; my $ref2 = bless ["ok - lexical destructionn"]; our $ref4 = bless ["ok - our destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } => ok - dynamic destruction ok - lexical destruction ok - package destruction ok - our destruction DESTRUCT Thursday, May 8, 14
  • 11. perl debugging: -DD (-D? => D Cleaning up) $ ./ccode197_o3 -DD EXECUTING... ok - dynamic destruction ok - lexical destruction Cursing named global static sv_arena: Calling FINALE::DESTROY ok - package destruction sv_arena: 0x7ff9b982f600 - 0x7ff9b98305f0 (170) sv_arena: 0x7ff9b982ae00 - 0x7ff9b982bdf0 (170) sv_arena: 0x7ff9b9807800 - 0x7ff9b98087f0 (170) Cleaning named glob IO object: SV = PVIO(0x7ff9b982ce00) at 0x7ff9b982b7a8 REFCNT = 2 FLAGS = (OBJECT) STASH = 0x7ff9b982b268! "IO::File" ... DESTRUCT Thursday, May 8, 14
  • 12. ok - dynamic destruction ok - lexical destruction Cursing named global static sv_arena: Calling FINALE::DESTROY ok - package destruction Cleaning object ref: SV = IV(0x10076dce8) at 0x10076dcf8 REFCNT = 1 FLAGS = (ROK) RV = 0x7fc549802aa8 SV = PVAV(0x7fc549005530) at 0x7fc549802aa8 FLAGS = (OBJECT) STASH = 0x7fc5490287f8! "FINALE" FLAGS = (REAL) Elt No. 0 SV = PV(0x7fc549002780) at 0x7fc549802ac0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x7fc548d0ab50 "ok - our destructionn"0 CUR = 21 LEN = 32 ok - our destruction DESTRUCT Thursday, May 8, 14
  • 13. Thursday, May 8, 14
  • 14. DESTRUCT • Beware! Our current perlcc compiler does not do global destruction. • The new 5.14 compiler can do global destruction, but this is not stable yet Thursday, May 8, 14
  • 15. Takeaway package FINALE; { $ref3 = bless ["ok - package destructionn"]; my $ref2 = bless ["ok - lexical destructionn"]; our $ref4 = bless ["ok - our destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } Never use global destruction Thursday, May 8, 14
  • 16. Takeaway package FINALE; { $ref3 = bless ["ok - package destructionn"]; my $ref2 = bless ["ok - lexical destructionn"]; our $ref4 = bless ["ok - our destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } Never use global destruction Never use our objects, always my Thursday, May 8, 14
  • 17. Why? • With old perlcc DESTROY methods of global or our objects are not called. Thursday, May 8, 14
  • 18. Questions? Thursday, May 8, 14

×