Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Emotions are alien to me. I'm a scientist. -- Spock, "This Side of Paradise", stardate 3417.3


devel / comp.lang.ada / Re: Beginners question

SubjectAuthor
* Beginners questionuq5huo...@gmail.com
`* Re: Beginners questionNiklas Holsti
 +- Re: Beginners questionuq5huo...@gmail.com
 `- Re: Beginners questionuq5huo...@gmail.com

1
Beginners question

<bd7154c8-21af-468e-910a-5a0847255eafn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6285&group=comp.lang.ada#6285

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5bc8:: with SMTP id b8mr4402776qtb.247.1636727568360;
Fri, 12 Nov 2021 06:32:48 -0800 (PST)
X-Received: by 2002:a25:e4c7:: with SMTP id b190mr17082597ybh.204.1636727568192;
Fri, 12 Nov 2021 06:32:48 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 12 Nov 2021 06:32:48 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=109.43.49.191; posting-account=3ciIaAoAAAA6pCfildcdAcuc3UQuirtL
NNTP-Posting-Host: 109.43.49.191
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bd7154c8-21af-468e-910a-5a0847255eafn@googlegroups.com>
Subject: Beginners question
From: uq5huoix...@gmail.com (uq5huo...@gmail.com)
Injection-Date: Fri, 12 Nov 2021 14:32:48 +0000
Content-Type: text/plain; charset="UTF-8"
 by: uq5huo...@gmail.com - Fri, 12 Nov 2021 14:32 UTC

Hi,

I'm beginning to play with Ada, and run into this

with Ada.Text_IO; use Ada.Text_IO;
procedure Learn is
subtype Alphabet is Character range 'A' .. 'Z';
begin
Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last);
end Learn;

Now I want to play a bit with the code ... and this fails and I don't get why and how to solve.

Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last-1);
or
Put_Line ("Learning Ada from " & Alphabet'First & " to " & (Alphabet'Last-1));

Anyone more expirienced can explain this to my, please?

Re: Beginners question

<iv7f91F39pmU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6286&group=comp.lang.ada#6286

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Beginners question
Date: Fri, 12 Nov 2021 17:24:17 +0200
Organization: Tidorum Ltd
Lines: 38
Message-ID: <iv7f91F39pmU1@mid.individual.net>
References: <bd7154c8-21af-468e-910a-5a0847255eafn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net q6Oo0sJVudDHS8kZwZqqlwyCeMlaPMlX3/8J/lf+IGJ/xj9WKy
Cancel-Lock: sha1:+jmbMghVrqKApahyI2QqUgDls5Q=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <bd7154c8-21af-468e-910a-5a0847255eafn@googlegroups.com>
Content-Language: en-US
 by: Niklas Holsti - Fri, 12 Nov 2021 15:24 UTC

On 2021-11-12 16:32, uq5huo...@gmail.com wrote:
> Hi,
>
> I'm beginning to play with Ada, and run into this
>
> with Ada.Text_IO; use Ada.Text_IO;
> procedure Learn is
> subtype Alphabet is Character range 'A' .. 'Z';
> begin
> Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last);
> end Learn;
>
> Now I want to play a bit with the code ... and this fails and I don't get why and how to solve.
>
> Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last-1);
> or
> Put_Line ("Learning Ada from " & Alphabet'First & " to " & (Alphabet'Last-1));
>
> Anyone more expirienced can explain this to my, please?

The Character type is not an integer type (unlike "char" in C), so you
cannot subtract 1 from a Character (or an Alphabet value). Character is
an enumeration type in Ada.

To get the Alphabet value immediately preceding Alphabet'Last, use the
Pred ("predecessor") attribute function:

Alphabet'Pred (Alphabet'Last)

If you need to take larger strides in the Alphabet enumeration, you can
use the Pos and Val attribute functions. Pos returns the "position
number" of its argument, and that is an integer. Val performs the
opposite mapping. For example, to get the Alphabet value that is three
positions before Alphabet'Last, you can do

Alphabet'Val (Alphabet'Pos (Alphabet'Last) - 3)

Re: Beginners question

<55ac4ea4-da26-4c62-9a30-f32cf241a347n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6287&group=comp.lang.ada#6287

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:4044:: with SMTP id i4mr10742218qko.271.1636731842454;
Fri, 12 Nov 2021 07:44:02 -0800 (PST)
X-Received: by 2002:a5b:502:: with SMTP id o2mr16175281ybp.452.1636731842228;
Fri, 12 Nov 2021 07:44:02 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 12 Nov 2021 07:44:02 -0800 (PST)
In-Reply-To: <iv7f91F39pmU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=109.43.49.191; posting-account=3ciIaAoAAAA6pCfildcdAcuc3UQuirtL
NNTP-Posting-Host: 109.43.49.191
References: <bd7154c8-21af-468e-910a-5a0847255eafn@googlegroups.com> <iv7f91F39pmU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <55ac4ea4-da26-4c62-9a30-f32cf241a347n@googlegroups.com>
Subject: Re: Beginners question
From: uq5huoix...@gmail.com (uq5huo...@gmail.com)
Injection-Date: Fri, 12 Nov 2021 15:44:02 +0000
Content-Type: text/plain; charset="UTF-8"
 by: uq5huo...@gmail.com - Fri, 12 Nov 2021 15:44 UTC

Niklas Holsti schrieb am Freitag, 12. November 2021 um 16:24:20 UTC+1:
> On 2021-11-12 16:32, uq5huo...@gmail.com wrote:
> > Hi,
> >
> > I'm beginning to play with Ada, and run into this
> >
> > with Ada.Text_IO; use Ada.Text_IO;
> > procedure Learn is
> > subtype Alphabet is Character range 'A' .. 'Z';
> > begin
> > Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last);
> > end Learn;
> >
> > Now I want to play a bit with the code ... and this fails and I don't get why and how to solve.
> >
> > Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last-1);
> > or
> > Put_Line ("Learning Ada from " & Alphabet'First & " to " & (Alphabet'Last-1));
> >
> > Anyone more expirienced can explain this to my, please?
> The Character type is not an integer type (unlike "char" in C), so you
> cannot subtract 1 from a Character (or an Alphabet value). Character is
> an enumeration type in Ada.
>
> To get the Alphabet value immediately preceding Alphabet'Last, use the
> Pred ("predecessor") attribute function:
>
> Alphabet'Pred (Alphabet'Last)
>
> If you need to take larger strides in the Alphabet enumeration, you can
> use the Pos and Val attribute functions. Pos returns the "position
> number" of its argument, and that is an integer. Val performs the
> opposite mapping. For example, to get the Alphabet value that is three
> positions before Alphabet'Last, you can do
>
> Alphabet'Val (Alphabet'Pos (Alphabet'Last) - 3)

Dear Niklas,
thanks for the explanation. So I run into the strong typing and Ada prevents me to programm C-like. I really like that. :-)
I will read more onto the attributes to get familar with this.

Re: Beginners question

<ccf93f2f-be4d-4e48-8f00-39397f6204b4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6288&group=comp.lang.ada#6288

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:30a:: with SMTP id q10mr17209853qtw.267.1636731896508;
Fri, 12 Nov 2021 07:44:56 -0800 (PST)
X-Received: by 2002:a5b:846:: with SMTP id v6mr16526161ybq.457.1636731896342;
Fri, 12 Nov 2021 07:44:56 -0800 (PST)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 12 Nov 2021 07:44:56 -0800 (PST)
In-Reply-To: <iv7f91F39pmU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=109.43.49.191; posting-account=3ciIaAoAAAA6pCfildcdAcuc3UQuirtL
NNTP-Posting-Host: 109.43.49.191
References: <bd7154c8-21af-468e-910a-5a0847255eafn@googlegroups.com> <iv7f91F39pmU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ccf93f2f-be4d-4e48-8f00-39397f6204b4n@googlegroups.com>
Subject: Re: Beginners question
From: uq5huoix...@gmail.com (uq5huo...@gmail.com)
Injection-Date: Fri, 12 Nov 2021 15:44:56 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1329
 by: uq5huo...@gmail.com - Fri, 12 Nov 2021 15:44 UTC

Dear Niklas,
thanks for the explanation. So I run into the strong typing and Ada prevents me to programm C-like. I really like that. :-)
I will read more onto the attributes to get familar with this.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor