comp.lang.ada
 help / color / mirror / Atom feed
* qualified expressions acting as names - not accepted?
@ 2016-08-21 15:56 G.B.
  2016-08-22  1:25 ` Shark8
  2016-08-22 10:00 ` AdaMagica
  0 siblings, 2 replies; 4+ messages in thread
From: G.B. @ 2016-08-21 15:56 UTC (permalink / raw)


The compiler accepts line (1) below, but neither (2) or (3).
It says it is expecting Standard.Integer, not Standard.Boolean.
Is this a bug in the program or bug in the compiler?
(String'("AZ")(1) in a similar program is accepted.)

procedure Qualified is
    type S is array (Boolean) of Character;
    
    X: Character;
    Z: constant S := "AZ";
begin
    X := Z       (False);	-- (1)
    X := S'(Z)   (False);	-- (2)
    X := S'("AZ")(False);	-- (3)
end;


-- 
"HOTDOGS ARE NOT BOOKMARKS"
Springfield Elementary teaching staff


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: qualified expressions acting as names - not accepted?
  2016-08-21 15:56 qualified expressions acting as names - not accepted? G.B.
@ 2016-08-22  1:25 ` Shark8
  2016-08-22 10:00 ` AdaMagica
  1 sibling, 0 replies; 4+ messages in thread
From: Shark8 @ 2016-08-22  1:25 UTC (permalink / raw)


>     X := S'("AZ")(False);	-- (3)

This should be X := S'('A','Z')(False);

>     X := S'(Z)   (False);	-- (2)

This should be compilable, as you're essentially asserting that Z is type-S, and accessing False should result in a character.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: qualified expressions acting as names - not accepted?
  2016-08-21 15:56 qualified expressions acting as names - not accepted? G.B.
  2016-08-22  1:25 ` Shark8
@ 2016-08-22 10:00 ` AdaMagica
  2016-08-23  7:03   ` G.B.
  1 sibling, 1 reply; 4+ messages in thread
From: AdaMagica @ 2016-08-22 10:00 UTC (permalink / raw)


indexed_component ::= prefix(expression {, expression})
prefix ::= name | implicit_dereference
name ::= 
     direct_name | explicit_dereference
   | indexed_component | slice
   | selected_component | attribute_reference
   | type_conversion | function_call
   | character_literal | qualified_expression
   | generalized_reference | generalized_indexing
qualified_expression ::= 
   subtype_mark'(expression) | subtype_mark'aggregate

With this excerpt from the syntax, it looks like your compiler has a problem.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: qualified expressions acting as names - not accepted?
  2016-08-22 10:00 ` AdaMagica
@ 2016-08-23  7:03   ` G.B.
  0 siblings, 0 replies; 4+ messages in thread
From: G.B. @ 2016-08-23  7:03 UTC (permalink / raw)


On 22.08.16 12:00, AdaMagica wrote:
> With this excerpt from the syntax, it looks like your compiler has a problem.

So it seems. I have dropped a note.

Apparently, the compiler treats arrays of components of
type Character specially (also those of type Wide_Character,
or of type Wide_Wide_Character). Substituting a user defined
character type for the component type restores the expected
behavior.


-- 
"HOTDOGS ARE NOT BOOKMARKS"
Springfield Elementary teaching staff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-23  7:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-21 15:56 qualified expressions acting as names - not accepted? G.B.
2016-08-22  1:25 ` Shark8
2016-08-22 10:00 ` AdaMagica
2016-08-23  7:03   ` G.B.

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