:: Re: [DNG] GoLUG needs an ADA presen…
Top Page
Delete this message
Reply to this message
Author: Didier Kryn
Date:  
To: dng
Subject: Re: [DNG] GoLUG needs an ADA presentation
Le 18/08/2024 à 13:35, Steve Litt a écrit :
> Hi all,
>
> Several of you are ADA experts. I'd like GoLUG's October online
> presentation to be on ADA. Here's what's needed:
>
> * Hello world, editor and command line only
>
> * Branching and looping
>
> * Use of variables including numbers, structures, arrays, strings, and
>    the equivalent of Python dicts if ADA has those.
>
> * Discussion of best practices
>
> * Hello world GUI application
>
> * Discussion of why ADA is superior.
>

    It's been ten years since I read/wrote my last instruction of Ada;
therefore I would be unable to write a program now. Will try to do
something though.

    The most striking thing, compared to C is that the Ada programmer,
except when explicitely interfacing to hardware, should never think
hardware. Instead, a variable type should match the properties of the
value it represents, eg:

type Year_Day is range 1..366;

subtype Year_Duration is Year_Day range 365..366;

    It is not your concern what size of register and storage the
compiler will use to store this type.

    You are granted that the variables declared with the type and
subtype above will always be in the specified range. If, as the result
of a computation, it would fall outside, this would raise the exception
Constraint_Error.

    About types and subtypes: operations are forbidden between
different types, unless you define them, which requires using explicit
casts. Within a same type, operations are automatically allowed, even
between different subtypes, but, of course, the range of the result is
always verified.

--     Didier