* "strings are delimited by double quote character", where there's a character variable
@ 2017-12-01 15:08 Mehdi Saada
2017-12-01 16:38 ` A. Cervetti
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Mehdi Saada @ 2017-12-01 15:08 UTC (permalink / raw)
I got a a Character variable gnat says it is a String, while functions taking it as parameter take only Characters. Mentions of the variable in the procedure:
C: Character := ''; -- strings are delimited by double quote character
while C /= '' loop
Get(C); PUSH(C);
end loop;
while (C /= '') loop -- same here
Get(C);
PUSH(C);
end loop;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 15:08 "strings are delimited by double quote character", where there's a character variable Mehdi Saada
@ 2017-12-01 16:38 ` A. Cervetti
2017-12-01 16:43 ` AdaMagica
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: A. Cervetti @ 2017-12-01 16:38 UTC (permalink / raw)
A Character literal cannot be empty, i.e. it can be 'A'. ' ', but not ''.
So the compiler assumes you are trying to define an empty string ("") and warns you accordingly.
A.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 15:08 "strings are delimited by double quote character", where there's a character variable Mehdi Saada
2017-12-01 16:38 ` A. Cervetti
@ 2017-12-01 16:43 ` AdaMagica
2017-12-01 16:49 ` Jeffrey R. Carter
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: AdaMagica @ 2017-12-01 16:43 UTC (permalink / raw)
C: Character := ' '; -- a space character
S: String := " "; -- a string holding one space character
empty: String := ""; -- a string holding nothing
S(1) = C
S = C is illegal - different types left and right
I'm not sure I understand your problem. Hope this helps.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 15:08 "strings are delimited by double quote character", where there's a character variable Mehdi Saada
2017-12-01 16:38 ` A. Cervetti
2017-12-01 16:43 ` AdaMagica
@ 2017-12-01 16:49 ` Jeffrey R. Carter
2017-12-01 18:13 ` Mehdi Saada
2017-12-01 17:23 ` Dennis Lee Bieber
2017-12-01 19:09 ` Shark8
4 siblings, 1 reply; 9+ messages in thread
From: Jeffrey R. Carter @ 2017-12-01 16:49 UTC (permalink / raw)
On 12/01/2017 04:08 PM, Mehdi Saada wrote:
> C: Character := ''; -- strings are delimited by double quote character
'' is not a Character. It's not any legal Ada construct. The only place '' can
occur in Ada is in a comment or a string literal.
Apparently the most common reason for '' that the GNAT error-message writers
have seen is as a typo for "", hence the error message, which would be
meaningful in such a case. Not very useful for someone who doesn't understand
what a Character is.
--
Jeff Carter
"We call your door-opening request a silly thing."
Monty Python & the Holy Grail
17
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 15:08 "strings are delimited by double quote character", where there's a character variable Mehdi Saada
` (2 preceding siblings ...)
2017-12-01 16:49 ` Jeffrey R. Carter
@ 2017-12-01 17:23 ` Dennis Lee Bieber
2017-12-01 17:44 ` Dennis Lee Bieber
2017-12-01 19:09 ` Shark8
4 siblings, 1 reply; 9+ messages in thread
From: Dennis Lee Bieber @ 2017-12-01 17:23 UTC (permalink / raw)
Is there a question somewhere in this?
On Fri, 1 Dec 2017 07:08:39 -0800 (PST), Mehdi Saada <00120260a@gmail.com>
declaimed the following:
>I got a a Character variable gnat says it is a String, while functions taking it as parameter take only Characters. Mentions of the variable in the procedure:
>C: Character := ''; -- strings are delimited by double quote character
>while C /= '' loop
> Get(C); PUSH(C);
>end loop;
>while (C /= '') loop -- same here
> Get(C);
> PUSH(C);
>end loop;
I see nothing wrong with the above. There are NO " characters in the
example. There are pairs of ' characters, which are used to delimit
CHARACTER -- which would be obvious by just stepping the cursor through
them.
An empty string would be... := "";
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 17:23 ` Dennis Lee Bieber
@ 2017-12-01 17:44 ` Dennis Lee Bieber
0 siblings, 0 replies; 9+ messages in thread
From: Dennis Lee Bieber @ 2017-12-01 17:44 UTC (permalink / raw)
On Fri, 01 Dec 2017 12:23:28 -0500, Dennis Lee Bieber
<wlfraed@ix.netcom.com> declaimed the following:
> I see nothing wrong with the above. There are NO " characters in the
>example. There are pairs of ' characters, which are used to delimit
>CHARACTER -- which would be obvious by just stepping the cursor through
>them.
>
> An empty string would be... := "";
And a small mea culpa -- I've not had to use character, so overlooked
that empty character is invalid.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 16:49 ` Jeffrey R. Carter
@ 2017-12-01 18:13 ` Mehdi Saada
0 siblings, 0 replies; 9+ messages in thread
From: Mehdi Saada @ 2017-12-01 18:13 UTC (permalink / raw)
Well, I do understand what a character is (a certain enumeration litteral), but I did nonetheless mixed up with the idea of a null string or size 0. I'll initialise character variables with Ada.Latin_1.Nul then. Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 15:08 "strings are delimited by double quote character", where there's a character variable Mehdi Saada
` (3 preceding siblings ...)
2017-12-01 17:23 ` Dennis Lee Bieber
@ 2017-12-01 19:09 ` Shark8
2017-12-05 21:45 ` Keith Thompson
4 siblings, 1 reply; 9+ messages in thread
From: Shark8 @ 2017-12-01 19:09 UTC (permalink / raw)
On Friday, December 1, 2017 at 8:08:41 AM UTC-7, Mehdi Saada wrote:
> I got a a Character variable gnat says it is a String, while functions taking it as parameter take only Characters. Mentions of the variable in the procedure:
> C: Character := ''; -- strings are delimited by double quote character
> while C /= '' loop
> Get(C); PUSH(C);
> end loop;
> while (C /= '') loop -- same here
> Get(C);
> PUSH(C);
> end loop;
The character you are using is referred to in Ada as "Apostrophe" (See Package Ada.Characters.Latin_1) the character referred to as a double-quote character is "Quotation". -- Respectively, these are Character'(''') and Character'('"').
String and Character are two separate types, though related, and are therefore not interchangeable. / A String is an array of Character, and thus can be specified via aggregate as ('H', 'e', 'l', 'l', 'o')... this would be rather tedious and so there exists a bit of syntactic sugar to specify a String: these are the Quotation delimiters and result in the previous value also being representable as "Hello".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: "strings are delimited by double quote character", where there's a character variable
2017-12-01 19:09 ` Shark8
@ 2017-12-05 21:45 ` Keith Thompson
0 siblings, 0 replies; 9+ messages in thread
From: Keith Thompson @ 2017-12-05 21:45 UTC (permalink / raw)
Shark8 <onewingedshark@gmail.com> writes:
> On Friday, December 1, 2017 at 8:08:41 AM UTC-7, Mehdi Saada wrote:
>> I got a a Character variable gnat says it is a String, while
>> functions taking it as parameter take only Characters. Mentions of
>> the variable in the procedure:
>> C: Character := ''; -- strings are delimited by double quote character
>> while C /= '' loop
>> Get(C); PUSH(C);
>> end loop;
>> while (C /= '') loop -- same here
>> Get(C);
>> PUSH(C);
>> end loop;
>
> The character you are using is referred to in Ada as "Apostrophe" (See
> Package Ada.Characters.Latin_1) the character referred to as a
> double-quote character is "Quotation". -- Respectively, these are
> Character'(''') and Character'('"').
It's not an apostrophe, it's a syntax error, and it doesn't refer to any
character value.
''' -- apostrophe character
'' -- syntax error
"" -- empty string
"'" -- string containing a single apostrophe
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-12-05 21:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-01 15:08 "strings are delimited by double quote character", where there's a character variable Mehdi Saada
2017-12-01 16:38 ` A. Cervetti
2017-12-01 16:43 ` AdaMagica
2017-12-01 16:49 ` Jeffrey R. Carter
2017-12-01 18:13 ` Mehdi Saada
2017-12-01 17:23 ` Dennis Lee Bieber
2017-12-01 17:44 ` Dennis Lee Bieber
2017-12-01 19:09 ` Shark8
2017-12-05 21:45 ` Keith Thompson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox