The thing is that your proposed language is almost raw code. ;-)
I think that splitting everything up in different layers of abstraction
is the way to go. I wasn't criticizing the concept.
This is completely subjective, but I tend to dislike mini-languages. E.g. although I use Template Toolkit, I'd be much happier if it used a slightly modified Perl (which the only major difference would be the removal of curly braces) instead of its own language. I even considered using
Template::PSP but it really doesn't have all the features I need.
Going back to the specific example you gave,
Class::DBI and
Catalyst are substantially different from hand-written SQL and plain CGI coding. While your proposed language is not.
If I were to implement a verification language, the "code" would probably be some sort of subset of YAML (not because it would ease parsing, but because I really like YAML) and look something like this:
# type checking
parameters:
# + concatenates rules, pad does smart padding
flight_number: char(2) + pad(integer(0 .. 9999))
flight_type: char(1)
# variable passed as a parameter to the template
total_seats: integer(0 .. :total_seats)
occupied_seats: integer(0 .. :total_seats)
# length checks the list, "of string" could be implicit
passenger_list: list(0 .. :total_seats) of string
# further validation and processing
processing:
# & references a previously declared field
# :flights_table could be a list or a hash
# this might be more appropriate to be on
# the previous "parameters" instead of here
- exists &flight_number in :flights_table
# maps the flight type code into a descriptive string
# using the flight_types hash
- map &flight_type into :flight_types
# some simple and obvious checks
- check $occupied_seats < &total_seats
- check &passenger_list = &occupied_seats
# in-template variable declaration
declare:
flight_types:
A: Commercial
B: Non-Commercial
C: Cargo
In fact, I actually really liked this idea. I might consider implementing it, if I have the time. ;-)
acid06
perl -e "print pack('h*', 16369646), scalar reverse $="
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.