Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Nvidia, in the past of other companies such as Iagination Technologies, MIPS, Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Thursday, January 26, 2012

Perl test brackets with deterministic finalization

I just realized that you can use deterministic finalization in Perl just like C++. Yay!
{
    package Brackets;
    # my first attempt to use determinsitic finalization in Perl;
    sub name {
 my $self = {};
 $self->{name} = shift @_;
 bless $self;
 print "{name}>\n";
 return $self;
    }
    sub DESTROY {
 my $self = shift @_;
 print "{name}>\n";
    }
}
Note that I use my "pseudo-XML" notation:
<TEST START name>
...
</TEST END name>
It's not nice to violate the standard, but IMHO this is a alot easirr to read than
<TEST context="START" name="name">
...
</TEST context="END" name="name">
and readability is a concern - since I plop these things in test output read by my human coworkers. Human coworkers who really don't like XML because it is so ugly. I can readily translate my pseudo XML into real XML, in case I wanted to use any real XML tools. And can do many operations without such translation. Unfortunately, there aren't many real XML tools to be used withot a lot of work :-(. I need to fix up my pseudo-XML UNIX command line tools, suitable fr use in pipezs and so on.

No comments: