[Info-vax] Modern software development for VMS, was: Re: source control and semantics (Re: Why so much Unix envy?)
Shark8
OneWingedShark at gmail.com
Mon Sep 15 14:05:42 EDT 2014
On 9/14/2014 9:40 AM, David Froble wrote:
> What's wrong with directories containing source files, build files, and
> such?
The reason that directories/source-files is bad is because it makes
things like compiling/linking dependent on path-searching; it also makes
things a bit more difficult for dependency-management and encourages
inefficient practices/procedures (i.e. recursive make).
The problem with text is essentially the same problem as "a string" vs.
"an identifier" (the identifier has rules it must follow, like in Ada,
for example: a string containing only alphanumeric-characters or
underscore, with the following restrictions: it cannot start with a
digit or underscore, cannot end with an underscore, and cannot contain
successive underscores). -- Now if you have an identifier-type that you
have as a key to a map to a record indicating type-value-location you
have a Symbol-table (with the nice property that all the symbols are
valid identifiers).
Or, a bit more on the mundane side, consider DB-applications and
ensuring [DB] consistency and proper-processing; you could use the
following to ensure that (a) all SSNs are correctly and consistently
formatted, (b) that the parameters and return-values conform to those
rules, and (c) that when [not if] one of the developers/maintainers
inserts bad data into the DB it will be caught:
> -- SSN format: ###-##-####
> Subtype Social_Security_Number is String(1..11)
> with Dynamic_Predicate =>
> (for all Index in Social_Security_Number'Range =>
> (case Index is
> when 4|7 => Social_Security_Number(Index) = '-',
> when others => Social_Security_Number(Index) in '0'..'9'
> )
> );
or ensuring dates are consistently-formatted and valid:
> Package Date_String is
>
> -- Date-String format: ####-##-##
> Subtype Date_String is String(1..10)
> with Dynamic_Predicate =>
> (for all Index in Date_String'Range =>
> (case Index is
> when 5|8 => Date_String(Index) = '-',
> when others => Date_String(Index) in '0'..'9'
> )
> ) and then -- short-circut boolean, ensures the above first
> (case Month(Date_String) is
> when 1 | 3 | 5 | 7 | 8 | 10 | 12 => Day(Date_String)'Valid,
> when 4 | 6 | 9 | 11 => Day(Date_String) in 1..30,
> when 2 => (if Is_Leap_Year(Date_String) then Day(Date_String) in 1..30
> else Day(Date_String) in 1..29)
> );
>
>
> Private
>
> Subtype Month_Type is Natural range 1..12;
> subtype Day_Type is Natural range 1..31;
>
> Function Year ( Input : String ) Return Natural is
> ( Natural'Value(Input(Input'First..Input'First+3)) );
> Function Month( Input : String ) Return Month_Type is
> ( Natural'Value(Input(Input'First+5..Input'First+6)) );
> Function Day ( Input : String ) Return Day_Type is
> ( Natural'Value(Input(Input'Last-1..Input'Last)) );
>
> -- METHOD FOR DETERMINING LEAP-YEAR:
> -- (1) If the year is evenly divisible by 4, go to step 2.
> -- Otherwise, go to step 5.
> -- (2) If the year is evenly divisible by 100, go to step 3.
> -- Otherwise, go to step 4.
> -- (3) If the year is evenly divisible by 400, go to step 4.
> -- Otherwise, go to step 5.
> -- (4) The year is a leap year (it has 366 days).
> -- (5) The year is not a leap year (it has 365 days).
> --
> -- CONCISELY:
> -- Year Mod 400 = 0 or (Year Mod 4 = 0 and Year Mod 100 /= 0)
> Function Is_Leap_Year( Year : Natural ) Return Boolean is
> (Year Mod 400 = 0 or (Year Mod 4 = 0 and Year Mod 100 /= 0));
> Function Is_Leap_Year( Input : String ) Return Boolean is
> ( Is_Leap_Year(Year(Input)) );
>
> End Date_String;
IOW, to store programs as text is to ignore that there are constraints
as to the validity thereof.
More information about the Info-vax
mailing list