From: Shark8 <OneWingedShark@gmail.com>
Subject: Re: Ada's ranking of popularity at IEEE Spectrum
Date: Tue, 08 Jul 2014 20:30:55 -0600
Date: 2014-07-08T20:30:55-06:00 [thread overview]
Message-ID: <yP1vv.130672$R01.7299@fx11.iad> (raw)
In-Reply-To: <f5e74f05-a4db-44b6-80f4-086870661e41@googlegroups.com>
On 08-Jul-14 17:03, sbelmont700@gmail.com wrote:
> So we, as a community, cannot easily divide up the work in a component like manner,
> and are usually forced to start all way down at the O/S interface level *for every
> single project*.
Why would we need to start at the OS level for TLS? Yes, I realize we'll
need to depend on X.509 and ASN.1, but I don't see why we cannot write
[at least those] in a generally platform-independent manner.
In fact, given Ada's reputation as being highly-portable, wouldn't
writing theses basic [fundamental, not simple] components be a /good/ thing?
> And again, even if you do manage to create an elegant Ada interface to OpenSSL,
> it's not going to be OpenSSL, because OpenSSL is an untyped C API that is anathema
> to everything Ada. The better you make it, the further away from the standard you
> get, and the less people are going to want to use it.
I said TLS, not OpenSSL.
But even so, what's stopping someone from taking a formally-verified TLS
component and wrapping/exporting it for C [and OpenSSL] compatibility?
How would that be buying into C's type-system?
e.g. what is stopping us from exporting to C-interface if we have a
string-date package? Sure values and such won't be protected on the
C-side, but we know about out Ada side, no?
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)
);
SUBTYPE C_Date_String is Interfaces.C.Strings.char_array_access with
Dynamic_Predicate =>
Interfaces.C.To_Ada(C_Date_String.All) in Date_String;
-- Whatever procedures we need to export.
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;
next prev parent reply other threads:[~2014-07-09 2:30 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-06 15:19 Ada's ranking of popularity at IEEE Spectrum Dan'l Miller
2014-07-06 16:25 ` gautier_niouzes
2014-07-06 17:18 ` Dan'l Miller
2014-07-06 18:03 ` Ludovic Brenta
2014-07-06 19:03 ` Dan'l Miller
2014-07-06 19:41 ` Ludovic Brenta
2014-07-07 7:03 ` Tero Koskinen
2014-07-06 22:15 ` Brad Moore
2014-07-07 13:14 ` Peter Chapin
2014-07-07 14:27 ` Dan'l Miller
2014-07-09 15:01 ` Brad Moore
2014-07-10 7:42 ` Maciej Sobczak
2014-07-10 13:56 ` Peter Chapin
2014-07-10 18:18 ` Nasser M. Abbasi
2014-07-10 18:30 ` Nasser M. Abbasi
2014-07-11 4:55 ` theanalogmachine
2014-07-11 11:56 ` G.B.
2014-07-07 8:37 ` Brian Drummond
2014-07-06 19:41 ` sbelmont700
2014-07-08 17:25 ` Shark8
2014-07-08 23:03 ` sbelmont700
2014-07-08 23:30 ` Jeffrey Carter
2014-07-09 0:29 ` sbelmont700
2014-07-09 2:30 ` Shark8 [this message]
2014-07-27 2:01 ` David Thompson
2014-07-27 20:19 ` sbelmont700
2014-07-28 3:53 ` Dan'l Miller
2014-07-07 0:17 ` Simon Clubley
2014-07-07 1:17 ` Nasser M. Abbasi
2014-07-07 6:11 ` Simon Wright
2014-07-07 6:30 ` Georg Bauhaus
2014-07-07 9:04 ` Brian Drummond
2014-07-07 13:33 ` Simon Wright
2014-07-07 16:11 ` Brian Drummond
2014-07-10 19:49 ` Marius Amado-Alves
2014-07-10 20:19 ` Shark8
2014-07-10 21:39 ` björn lundin
2014-07-10 22:54 ` Shark8
2014-07-11 7:26 ` Dmitry A. Kazakov
2014-07-11 7:37 ` Maciej Sobczak
2014-07-11 9:32 ` björn lundin
2014-07-12 21:43 ` Marius Amado-Alves
2014-07-13 8:52 ` björn lundin
2014-07-11 0:16 ` Simon Clubley
2014-07-11 0:40 ` Jeffrey Carter
2014-07-11 1:15 ` Shark8
2014-07-11 7:03 ` Simon Clubley
2014-07-08 20:10 ` gautier_niouzes
2014-07-10 13:30 ` Gerd
2014-07-10 15:14 ` Shark8
2014-07-10 19:16 ` Jeffrey Carter
2014-07-11 2:17 ` Dennis Lee Bieber
2014-07-11 0:39 ` gvdschoot
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox