comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: Q: Localizing type and package references
  2014-01-06  1:29  0% ` Jeffrey Carter
@ 2014-01-06  8:05  0%   ` Simon Wright
  0 siblings, 0 replies; 4+ results
From: Simon Wright @ 2014-01-06  8:05 UTC (permalink / raw)


Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:

> On 01/05/2014 04:55 PM, b.mcguinness747@gmail.com wrote:
>>
>> --------------------------------------------------------------------------------
>> -- Types - Declarations of data types and related packages
>> --------------------------------------------------------------------------------
>> with Ada.Characters;
>> with Ada.Characters.Wide_Latin_1;
>> with Ada.Strings;
>> with Ada.Strings.Wide_Maps;
>> with Ada.Strings.Wide_Unbounded;
>> with Ada.Wide_Characters;
>> with Ada.Wide_Characters.Handling;
>> with Ada.Wide_Text_IO;
>> with Ada.Wide_Text_IO.Text_Streams;
>>
>> package Types is
>>    package Chars         renames Ada.Characters.Wide_Latin_1;
>>    package Char_Handling renames Ada.Wide_Characters.Handling;
>>    package Char_IO       renames Ada.Wide_Text_IO;
>>    package Char_Maps     renames Ada.Strings.Wide_Maps;
>>    package Char_Streams  renames Ada.Wide_Text_IO.Text_Streams;
>>    package Char_Strings  renames Ada.Strings.Wide_Unbounded;
>>
>>    subtype Char        is Wide_Character;
>>    subtype Char_String is Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
>> end Types;
>>
>> and then tried referencing this from the main program file with:
>>
>> with Types;
>> use  Types;
>>
>> with Char_Strings;
>>
>> but the compiler (Gnat 4.6) complains that there is no file called
>> char_strings.ads.  I am not sure if I have made a simple mistake that
>> can be easily corrected to make this work, or if there is a different
>> approach that I should be trying.
>
> You can only with a library-level package, one not declared in
> anything else. Char_Strings is declared in package types, so it's not
> library level and can't be withed.

So, you can either reclare package Chars etc at library level: for
example, in char_strings.ads,

   with Ada.Strings.Wide_Unbounded;
   package Char_Strings  renames Ada.Strings.Wide_Unbounded;

or you can change your main program file to say

   with Types;
   use Types;
   use Types.Chars;
   use Types.Char_Handling;
   ...

or perhaps

   with Types;
   use Types;
   procedure Main is
      use Chars;
      use Char_Handling;
      ...

^ permalink raw reply	[relevance 0%]

* Re: Q: Localizing type and package references
  2014-01-05 23:55  7% Q: Localizing type and package references b.mcguinness747
@ 2014-01-06  1:29  0% ` Jeffrey Carter
  2014-01-06  8:05  0%   ` Simon Wright
  0 siblings, 1 reply; 4+ results
From: Jeffrey Carter @ 2014-01-06  1:29 UTC (permalink / raw)


On 01/05/2014 04:55 PM, b.mcguinness747@gmail.com wrote:
>
> --------------------------------------------------------------------------------
> -- Types - Declarations of data types and related packages
> --------------------------------------------------------------------------------
> with Ada.Characters;
> with Ada.Characters.Wide_Latin_1;
> with Ada.Strings;
> with Ada.Strings.Wide_Maps;
> with Ada.Strings.Wide_Unbounded;
> with Ada.Wide_Characters;
> with Ada.Wide_Characters.Handling;
> with Ada.Wide_Text_IO;
> with Ada.Wide_Text_IO.Text_Streams;
>
> package Types is
>    package Chars         renames Ada.Characters.Wide_Latin_1;
>    package Char_Handling renames Ada.Wide_Characters.Handling;
>    package Char_IO       renames Ada.Wide_Text_IO;
>    package Char_Maps     renames Ada.Strings.Wide_Maps;
>    package Char_Streams  renames Ada.Wide_Text_IO.Text_Streams;
>    package Char_Strings  renames Ada.Strings.Wide_Unbounded;
>
>    subtype Char        is Wide_Character;
>    subtype Char_String is Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
> end Types;
>
> and then tried referencing this from the main program file with:
>
> with Types;
> use  Types;
>
> with Char_Strings;
>
> but the compiler (Gnat 4.6) complains that there is no file called
> char_strings.ads.  I am not sure if I have made a simple mistake that
> can be easily corrected to make this work, or if there is a different
> approach that I should be trying.

You can only with a library-level package, one not declared in anything else. 
Char_Strings is declared in package types, so it's not library level and can't 
be withed.

-- 
Jeff Carter
"Spam! Spam! Spam! Spam! Spam! Spam! Spam! Spam!"
Monty Python's Flying Circus
53


^ permalink raw reply	[relevance 0%]

* Q: Localizing type and package references
@ 2014-01-05 23:55  7% b.mcguinness747
  2014-01-06  1:29  0% ` Jeffrey Carter
  0 siblings, 1 reply; 4+ results
From: b.mcguinness747 @ 2014-01-05 23:55 UTC (permalink / raw)


I want to write an Ada program using the Wide_Character type, but I might
want to move to Wide_Wide_Character later on.  So I want to localize all
references to Wide_Character and the associated standard Ada packages to
a single file that I can easily update.  If I was working in C++, I would
use typedefs to create pseudonyms and put these in a header file that I could
#include from various source files.  So I have tried to do something similar
in Ada.  I created the file types.ads:

--------------------------------------------------------------------------------
-- Types - Declarations of data types and related packages
--------------------------------------------------------------------------------
with Ada.Characters;
with Ada.Characters.Wide_Latin_1;
with Ada.Strings;
with Ada.Strings.Wide_Maps;
with Ada.Strings.Wide_Unbounded;
with Ada.Wide_Characters;
with Ada.Wide_Characters.Handling;
with Ada.Wide_Text_IO;
with Ada.Wide_Text_IO.Text_Streams;

package Types is
  package Chars         renames Ada.Characters.Wide_Latin_1;
  package Char_Handling renames Ada.Wide_Characters.Handling;
  package Char_IO       renames Ada.Wide_Text_IO;
  package Char_Maps     renames Ada.Strings.Wide_Maps;
  package Char_Streams  renames Ada.Wide_Text_IO.Text_Streams;
  package Char_Strings  renames Ada.Strings.Wide_Unbounded;

  subtype Char        is Wide_Character;
  subtype Char_String is Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
end Types;


and then tried referencing this from the main program file with:


with Types;
use  Types;

with Char_Strings;


but the compiler (Gnat 4.6) complains that there is no file called
char_strings.ads.  I am not sure if I have made a simple mistake that
can be easily corrected to make this work, or if there is a different
approach that I should be trying.

Help would be appreciated.

Thanks.

--- Brian


^ permalink raw reply	[relevance 7%]

* Re: The letter Sharp S and the English language
  @ 2013-03-25 19:48  4%   ` Georg Bauhaus
  0 siblings, 0 replies; 4+ results
From: Georg Bauhaus @ 2013-03-25 19:48 UTC (permalink / raw)


On 25.03.13 16:23, Adam Beneschan wrote:
> On Saturday, March 23, 2013 2:22:26 PM UTC-7, Georg Bauhaus wrote:
>> In case you remember a heated discussions of what � is,
>> whether it is an S-Z ligature or an S-S, and how to (not)
>> downcase "ACCESS", more evidence comes from Ireland of 1759,
>> in the signature of Arthur Guinne�,
>>
>> http://home.arcor.de/bauhaus/Ada/GUINNESS.jpg
> 
> That pretty clearly looks like two separate letters to me, although the two s's are in different styles.  But it isn't a ligature.  I'm not sure what your point is since I don't remember the original thread very well.

I'm investigating how Unicode enabled Ada can help me "export"
street names to Switzerland. Thus,

  To_Upper ("Xyz-Stra�e");  -- String or Wide_String

What interests me is whether or not this might or might not work in the
future, i.e. with Ada 2012, in the light of recent developments of
ISO/IEC 10646:

First, you'd typically not be writing '�' in Switzerland and instead
replace every occurrence with "ss". That's for both lower case and
upper case. (And also when using small caps). So, To_Upper's definition
won't help.

But! Since Ada 2005 there are two new twists. In 2008, ISO/IEC 10646
has published an official upper case character for '�', U+1E9E. And in
2010, official spelling (read: government; "amtlich") requires U+1E9E
in geographical names. These include street names.

http://141.74.33.52/stagn/Portals/0/101125_TopR5.pdf

Currently, GNAT's implementation of
 Ada.Wide_Characters.Handling.To_Upper
gives Wide_Character'Val (223) for To_Upper ('�'), AFAICS.

Unicode's CaseFolding.txt, if applicable, has two lines pertaining
to the matter,

1E9E; F; 0073 0073; # LATIN CAPITAL LETTER SHARP S
1E9E; S; 00DF; # LATIN CAPITAL LETTER SHARP S

So I'm wondering if Simple Case Mapping might mean that

  To_Upper (Wide_Character'('�'))

should return Wide_Character'Val (16#1E9E#) in Ada 2012.


('�' will thus continue to cause problems originating in web based form
entry fields and elsewhere, I'm almost sure. Just one out of many
experiences: a major fruit company's customer invoices have consistently
shown what looks like junk HTML right after "Stra" in my address for years.)




^ permalink raw reply	[relevance 4%]

Results 1-4 of 4 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2013-03-23 21:22     The letter Sharp S and the English language Georg Bauhaus
2013-03-25 15:23     ` Adam Beneschan
2013-03-25 19:48  4%   ` Georg Bauhaus
2014-01-05 23:55  7% Q: Localizing type and package references b.mcguinness747
2014-01-06  1:29  0% ` Jeffrey Carter
2014-01-06  8:05  0%   ` Simon Wright

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