150 likes | 266 Views
Module “Data::Locations”. “What on earth are Data::Locations?!” Steffen Beyer YAPC::Europe, London, UK, ICA, September 22-24 2000. Agenda. What is it good for? Example How does it work? Gory Details History Questions & Answers, Suggestions. What is it good for?.
E N D
Module “Data::Locations” “What on earth are Data::Locations?!” Steffen Beyer YAPC::Europe, London, UK, ICA, September 22-24 2000
Agenda • What is it good for? • Example • How does it work? • Gory Details • History • Questions & Answers, Suggestions
What is it good for? • Writing (almost) sequential streams of data, with some portions to be filled in later, after most or all of the stream has already been written - without using temporary files: • Web Content Management • Generating code in large IT projects • Mailings to multiple recipients • ...
Example Software Development Environment (Code Generators) Customer: Zeppelin-Caterpillar Development Platform: Unix Tool Language: Perl Production Platform: Mainframe MVS/CICS Production Language: PL/I Costs (just the tools!): approx. 4 man-years
Example • See • file "in.txt" • file "out.txt"
How does it work? (1/2) sd&m 6
How does it work? (2/2) • Data::Locations are implemented so that they behave as if they were an integral part of the Perl language: • you can send data to Data::Locations with "print" like to any other filehandle • you can read from Data::Locations with the "<>" operator as usual • Data::Locations go out of scope as any other Perl object • Data::Locations are fully suited for binary data • Data::Locations can be automatically dumped to a file, a pipe, a command etc. when program ends
Cookie • You can teach people with your head • You can kill people with an overhead • You can overkill people with two overheads
Gory Details • See • file "struct0.pl" • file "struct1.pl" • file "struct1.txt"
Data::Locations are typeglobs, filehandles and objects at the same time • The typeglob is blessed into the Data::Locations class • The filehandle is tied to the object (i.e., to itself, because Perl confuses typeglobs and filehandles) • The typeglob's slots ($, @, %) contain the object's data (the "@" slot actually contains the user's data) • Symbolic references are used as "weak references" for internal interconnections • The reference count is adjusted so that the Location will be destroyed when user's last reference goes out of scope • The symbol table %Data::Locations:: is used as index (for "weak reference" lookups and global destruction)
80’s 1988/1989 July 1997 : “Delta” macro processor (Delta GmbH) : “ProMAC” macro processor (sd&m GmbH) : Perl module “Data::Locations” (Free Software) History
DELTA macro processor • Product of Delta GmbH • Macro preprocessor to extend the capabilities of COBOL and PL/I • extendable with the help of a “PDL macro generator” • very cryptic • poor performance • hard-coded memory limits
ProMAC macro processor • String interpolation reminding of C preprocessor • built-in functions comparable to Perl • Regular expressions (similar to “egrep”) • “Module concept”: every subroutine is a separate file • Disastrous performance: 100% interpreted (even in loops) • Conceptual weaknesses
Questions & Answers, Suggestions • Please feel free to ask! • Suggestions are welcome.
Another Example Web Content Management Customer: Pentium GCC Group (http://www.goof.com/pcg/) Contact: Marc Lehmann <pcg@goof.com> Application: Generating status pages with bug reports for different releases and branches of development