From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5e54ec0ce937978 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!news.mv.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: String literals and wide_string literals - how? Date: Fri, 20 Apr 2007 10:55:45 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1177063665.093083.241580@e65g2000hsc.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1177080945 15513 192.74.137.71 (20 Apr 2007 14:55:45 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 20 Apr 2007 14:55:45 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:VKLFUnGoM3u/9KGbJ7dyJVxKQag= Xref: g2news1.google.com comp.lang.ada:15154 Date: 2007-04-20T10:55:45-04:00 List-Id: Gerd writes: > Hi all, > > if I have a string, then I can write a literal simply by writing > "abcd". But if I want write a wide_string literal, how do it? Same syntax. Context determines the type. String literals are not necessarily of type String; they can be of any "string type". A string type is any one-dimensional array of some character type. You can even do weird things like this: type Bit is ('0', '1'); type Bit_String is array (Positive range <>) of Bit; pragma Pack(Bit_String); X: constant Bit_String := "01011110"; Bit is a character type, and Bit_String is a string type. X can fit in 8 bits, by the way. > Assume I have two procedure of the form: > > procedure do_anything (s : string); > > procedure do_anything (w : wide_string); > > then > > do_anything ("abcd"); > > would call the first one. No, this is ambiguous, and therefore illegal. >... What would one write to call the second > one? To call either one, you need to qualify the type of the parameter: Do_Anything(String'("abcd")); Do_Anything(Wide_String'("abcd")); Blah: Wide_String := "abcd"; Do_Anything(Blah); > Is there something like the L"xxx" in C? That sort of syntax wouldn't work in Ada, because there are an unbounded number of string types. The qualified_expression syntax -- "type_name'(expression)" is used instead. - Bob