comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: newbie question: the " character inside a string
Date: 2000/05/24
Date: 2000-05-24T00:00:00+00:00	[thread overview]
Message-ID: <8ggste$fin$1@nnrp1.deja.com> (raw)
In-Reply-To: 8ggrm2$ein$1@nnrp1.deja.com

In article <8ggrm2$ein$1@nnrp1.deja.com>,
  Ted Dennison <dennison@telepath.com> wrote:
> In article <8ggcnp$83r$1@inf2.informatik.uni-stuttgart.de>,
>   "Martin Tobisch"
<tobiscmn@rupert.informatik.uni-stuttgart.de> wrote:
>
> > what do i have to do if i want to include a " inside of a
string?
>
> I know you already got a RTFM answer, but most manuals I have
> seen don't properly address string handling in Ada (it really
> ought to have its own chapter)

I disagree, all good Ada text books quite clearly describe how
to write string literals.

> and the LRM seems like overkill
> for such a simple question.

I disagree, first, you can immediately find the section by
looking for string (it is the first occurrence of the word
string in the main body of the RM), and you find the statements:

    4   A string_element is either a pair of quotation marks
        (""), or a single graphic_character other than a
        quotation mark.

and

5   The sequence of characters of a string_literal is formed
from the sequence of string_elements between the bracketing
quotation marks, in the given order, with a string_element that
is "" becoming a single quotation mark in the sequence of
characters, and any other string_element being
reproduced in the sequence.

This is not difficult stuff AT ALL, and people need to be able
to read paragraphs like the above and understand them.

Also the suggestion of using concatenation is way off base,
I strongly disagree with this because it introduces all kinds
of unnecessary semantics into the discussion about bounds and
the operation of concatenation. It is also ugly and has no
possible advantage over the normal "" quoting mechanism.

Learning to read manuals is at least as important to students
as learning Ada. In fact if we really want to be honest, the
ability to read manuals is probably much MORE important than
learning insignificant syntactic details about how to write
string literals in one particular language.

Yes, you can be lazy and get an answer to simple questions on
CLA, but as we very well know, when people have more complex
questions, they either don't get answers, or they get completely
inaccurate answers. The ability to learn for oneself from
reference materials is a vital one.







>
> There are two simple ways (I know of) to do this:
>
>   1)  Catenate a quotation character to your string eg:
>
>    Value : constant String := "The name is " & '"' &
> Some_String_Variable & '"';
>
>   2)  "Escape" the quotation character in the string literal
with
> another quotation character:
>
>    Value : constant String "= The name is """ &
Some_String_Variable &
> """";
>
> If you are using emacs, you'll probably want to stick to
method 2, since
> method 1 throws off Ada-mode's colorization.
>
> --
> T.E.D.
>
> http://www.telepath.com/~dennison/Ted/TED.html
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-05-24  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-24  0:00 newbie question: the " character inside a string Martin Tobisch
2000-05-24  0:00 ` Ted Dennison
2000-05-24  0:00   ` Robert Dewar [this message]
2000-05-24  0:00     ` Jeff Carter
2000-05-25  0:00   ` Geoff Bull
2000-05-24  0:00 ` David C. Hoos, Sr.
2000-05-24  0:00 ` Robert Dewar
2000-05-24  0:00 ` John English
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox