Few months ago I had a talk with gloom,
he was trying to convince me that JAVA was NEEDED to handle large projects...

I disagree (of course ;-) to this point of view, I believe that JAVA helps a lot,
but a good coding discipline can make it posible to code a large project in Perl.

For my part, I still prefer to see people code properly beccause they understand what they do
rather than beccause it's the only way allowed by the language.

We exchanged our ideas and Gloom made a point by talking about type checking.
As far as we know, there were no EASY way to do type checking in Perl,
and it's often a useful feature
(at least in the first stages of the program coding/testing)
However, deep in my heart, I KNEW that it should be possible to do it EASILY in Perl.
The ideas bounced in my minds for some weeks until I remind the Perl's Filter modules...
Although I've never used them, I remember I've seen amazing things made possible via the Filter's Modules...
So I installed the Filter::Simple modules, read the doc, and one hour later I came up with the 2 following proggies.

They were at first only made as a private 'proof of concept' for gloom, but I now wonder if it couldn't be more.
That's why I'm asking to the monastery :
Anyway, as it's my filter's firt use, and according to the little time I spent on it,
I probably made huge design errors, please feel free to correct me or give hints/advices...
I've also got a lot of other questions :
File : psychorigid.pm
package psychorigid; use Filter::Simple; use diagnostics; sub ctype { my @ctypes = split /;/,shift; my $code; my $argnum=0; # # Few tests added, we should probably add A LOT more for a real modul +e. # my %CODE = ( 'byte'=>' warn "arg !! ($_[!!]) IS NOT a byte" if $_[!!]!~/^-?\d{1,3 +}$/ || ($_[!!]>127) || ($_[!!]<-128);', 'short'=>' warn "arg !! ($_[!!]) IS NOT a short" if $_[!!]!~/^-?\d{1 +,5}$/ || ($_[!!]>32767) || ($_[!!]<-32768);', 'int'=>' warn "arg !! ($_[!!]) IS NOT an int" if $_[!!]!~/^-?\d{1,10 +}$/ || ($_[!!]>2147483647) || ($_[!!]<-2147483648);', 'char'=>' warn "arg !! ($_[!!]) IS NOT a char" if $_[!!]!~/^\w$/;', ); foreach my $ctype (@ctypes) { my $val=$CODE{$ctype}; $val=~s/!!/$argnum/g; $argnum++; $code.=$val."\n"; } return $code; } sub check { my $func_decl = shift; my $check_code = ctype(shift); return "$func_decl {\n$check_code" } FILTER { s/(sub\s+.+?)\s*{\s*#\s*!([^!]*)!/check($1,$2)/e; # # Uncomment the following line to see the changes applied by the filt +er # #print "\n$_\n"; }; 1;

File test.pl
#!/usr/bin/perl # # The following line can be commented and the code # will still be valid. # use psychorigid; # Add additional tests like some psychorigid languag +e ;-) sub toto { # !char;int! print "ok dans toto\n"; } toto('s','12245666666');

I
"Only Bad Coders Code Badly In Perl" (OBC2BIP)

In reply to psychorigid.pm or how to make Perl better ? by arhuman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.