comp.lang.ada
 help / color / mirror / Atom feed
* Is it really Ok to assert that the Ada syntax is a context-free grammar ?
@ 2008-02-20  0:47 Hibou57
  2008-02-20  2:06 ` Jeffrey R. Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Hibou57 @ 2008-02-20  0:47 UTC (permalink / raw)


Hi peoples living here :p

I got a doubt about [ARM 1.1.4-1]
> The form of an Ada program is described by means of a context-free syntax together with context-dependent requirements expressed by narrative rules.

But as pointed by someone, the grammar is not LR(1), due to the fact
(which is common to many other languages), that as an exemple X(Y) can
stand for a type cast, a function call, an array access, or even an
array slice, and this cannot be decided without knowlegde of the
context.

Am I wrong or is there really a so big mistake in the ARM ?

Please, tell me :( I want to know

Yannick




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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20  0:47 Is it really Ok to assert that the Ada syntax is a context-free grammar ? Hibou57
@ 2008-02-20  2:06 ` Jeffrey R. Carter
  2008-02-20 10:05   ` Martin Krischik
  2008-02-20  5:53 ` Niklas Holsti
  2008-02-20 16:43 ` Adam Beneschan
  2 siblings, 1 reply; 31+ messages in thread
From: Jeffrey R. Carter @ 2008-02-20  2:06 UTC (permalink / raw)


Hibou57 wrote:
> 
> But as pointed by someone, the grammar is not LR(1), due to the fact
> (which is common to many other languages), that as an exemple X(Y) can
> stand for a type cast, a function call, an array access, or even an
> array slice, and this cannot be decided without knowlegde of the
> context.

X (Y) cannot represent a type cast because Ada does not have anything called 
"type cast".

-- 
Jeff Carter
"Death awaits you all, with nasty, big, pointy teeth!"
Monty Python & the Holy Grail
20



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20  0:47 Is it really Ok to assert that the Ada syntax is a context-free grammar ? Hibou57
  2008-02-20  2:06 ` Jeffrey R. Carter
@ 2008-02-20  5:53 ` Niklas Holsti
  2008-02-20 16:43 ` Adam Beneschan
  2 siblings, 0 replies; 31+ messages in thread
From: Niklas Holsti @ 2008-02-20  5:53 UTC (permalink / raw)


Hibou57 wrote:
> Hi peoples living here :p
> 
> I got a doubt about [ARM 1.1.4-1]
> 
>> The form of an Ada program is described by means of a
>> context-free syntax together with context-dependent
>> requirements expressed by narrative rules.
> 
> But as pointed by someone, the grammar is not LR(1), due to the fact
> (which is common to many other languages), that as an exemple X(Y) can
> stand for a type cast, a function call, an array access, or even an
> array slice, and this cannot be decided without knowlegde of the
> context.

So? I believe several programming languages are defined by 
context-free grammars that are ambiguous unless such "static 
semantics" is used to guide the parsing.

Trying to express all language rules in the grammar leads either to 
wild proliferation of punctuation symbols (as in some Basics or 
Perl) or to a context-dependent grammar (as in the Algol 68 
two-level grammar).

 > Am I wrong or is there really a so big mistake in the ARM ?

The ARM doesn't say that the grammar is LR(1), only that it is 
context-free, and that is true.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20  2:06 ` Jeffrey R. Carter
@ 2008-02-20 10:05   ` Martin Krischik
  2008-02-20 10:34     ` Ludovic Brenta
  2008-02-20 18:27     ` Jeffrey R. Carter
  0 siblings, 2 replies; 31+ messages in thread
From: Martin Krischik @ 2008-02-20 10:05 UTC (permalink / raw)


Jeffrey R. Carter schrieb:
> Hibou57 wrote:
>>
>> But as pointed by someone, the grammar is not LR(1), due to the fact
>> (which is common to many other languages), that as an example X(Y) can
>> stand for a type cast, a function call, an array access, or even an
>> array slice, and this cannot be decided without knowledge of the
>> context.

You could also consider X (Y) as a (intrinsic) function in all cases - 
with X being a function which converts Y to type X or a function which 
accesses element Y from array X.

> X (Y) cannot represent a type cast because Ada does not have anything 
> called "type cast".

Not quite, if you consider "type cast" is a unchecked bit pattern copy - 
so if you define:

function X is new Unchecked_Conversion (...);

the X would indeed be a it "type cast".

Martin

-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 10:05   ` Martin Krischik
@ 2008-02-20 10:34     ` Ludovic Brenta
  2008-02-20 11:13       ` Dmitry A. Kazakov
                         ` (2 more replies)
  2008-02-20 18:27     ` Jeffrey R. Carter
  1 sibling, 3 replies; 31+ messages in thread
From: Ludovic Brenta @ 2008-02-20 10:34 UTC (permalink / raw)


Martin Krischik wrote:
> Jeffrey R. Carter schrieb:
> > X (Y) cannot represent a type cast because Ada does not have anything
> > called "type cast".
>
> Not quite, if you consider "type cast" is a unchecked bit pattern copy -
> so if you define:

Jeffrey is correct; it is not a "type cast", it is a "type conversion"
and there is no such thing as "Ada.Unchecked_Cast". Yes, this is nit-
picking; why would we choose Ada if we didn't care about details and
wording?

--
Ludovic Brenta.



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 10:34     ` Ludovic Brenta
@ 2008-02-20 11:13       ` Dmitry A. Kazakov
  2008-02-22  8:57         ` Stephen Leake
  2008-02-20 14:22       ` Hibou57
  2008-02-21 19:24       ` Martin Krischik
  2 siblings, 1 reply; 31+ messages in thread
From: Dmitry A. Kazakov @ 2008-02-20 11:13 UTC (permalink / raw)


On Wed, 20 Feb 2008 02:34:34 -0800 (PST), Ludovic Brenta wrote:

> Martin Krischik wrote:
>> Jeffrey R. Carter schrieb:
>>> X (Y) cannot represent a type cast because Ada does not have anything
>>> called "type cast".
>>
>> Not quite, if you consider "type cast" is a unchecked bit pattern copy -
>> so if you define:
> 
> Jeffrey is correct; it is not a "type cast", it is a "type conversion"
> and there is no such thing as "Ada.Unchecked_Cast".

ARM 13.7.2.

(Well, it says that an implementation may place some restrictions on it,
but it is not required to do so.)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 10:34     ` Ludovic Brenta
  2008-02-20 11:13       ` Dmitry A. Kazakov
@ 2008-02-20 14:22       ` Hibou57
  2008-02-20 15:19         ` Niklas Holsti
  2008-02-20 20:51         ` Robert A Duff
  2008-02-21 19:24       ` Martin Krischik
  2 siblings, 2 replies; 31+ messages in thread
From: Hibou57 @ 2008-02-20 14:22 UTC (permalink / raw)


On 20 fév, 11:34, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> Jeffrey is correct; it is not a "type cast", it is a "type conversion"
> and there is no such thing as "Ada.Unchecked_Cast". Yes, this is nit-
> picking; why would we choose Ada if we didn't care about details and
> wording?

Ok, forgive me for the english mistake : I use either type cast or
type conversion to mean the same thing. I will take care in the futur.

But I'm still not sure about the assertion that it is context free
(while, Ok, the AEM does not tell it is LR(1))

If it need name resolution to figure out what means the construct,
this is not a context-free grammar.

Is this construct the only one of the grammar which is not context-
free, or is there some others ?

It appears to be the only one of the kind, but I'm not sure.

Yannick



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 14:22       ` Hibou57
@ 2008-02-20 15:19         ` Niklas Holsti
  2008-02-20 18:34           ` Hibou57 (Yannick Duchêne)
  2008-02-20 20:51         ` Robert A Duff
  1 sibling, 1 reply; 31+ messages in thread
From: Niklas Holsti @ 2008-02-20 15:19 UTC (permalink / raw)


Hibou57 wrote:

> But I'm still not sure about the assertion that it is context free
> (while, Ok, the AEM does not tell it is LR(1))
> 
> If it need name resolution to figure out what means the construct,
> this is not a context-free grammar.

The *grammar* in the ARM is surely context-free. In each 
production, there is only one non-terminal symbol on the left-hand 
side, for example 6.4(3):

    function_call ::= prefix actual_parameter_part

In a context-dependent grammar, there would be several symbols on 
the left-hand side, before the "::=" sign.

The *Ada language* is not context-free, in the sense that the set 
of legal Ada programs cannot be defined by a context-free grammar. 
The same is true for all practical programming languages that allow 
user-defined identifiers with different properties, for example 
type identifiers and procedure identifiers, and that allow only 
some kinds of identifiers in some constructs. For example, you 
cannot "call" a type, but you can "call" a procedure.

The grammar in the ARM generates or accepts many strings that are 
not legal Ada programs. The "context-dependent narrative rules" are 
there to say which of these strings are legal Ada programs. This 
same definition method is used for most programming languages.

> Is this construct the only one of the grammar which is not context-
> free, or is there some others ?

Your are using the term "context-free" in some peculiar way, not in 
its usual meaning, I think.

It seems to me that you are really asking this question: given a 
*fragment* of an Ada program, for example "X(Y)", can this fragment 
be produced from more than one non-terminal grammar symbol?

I don't think that this has much to do with the context-freeness of 
the grammar, and I don't understand why you feel so strongly that 
there should be only one grammar symbol for each fragment.

For another example, consider the fragment

    delay 0.3

The way the grammar is now written, this fragment can (I think) be 
produced only from the non-terminal symbol delay_statement, by the 
rule in ARM 9.6(4). Does that make you happy? But look, the 
*meaning* of this fragment depends strongly on the context of this 
delay_statement: is it used as a

       simple_statement     (5.1(4))
or a  delay_alternative    (9.7.1(6))
or a  triggering_statement (9.7.4(4)) ?

These grammar rules could also be written without using the 
non-terminal symbol delay_statement, replacing it by the sequence 
consisting of the terminal symbol "delay" and the non-terminal 
symbol "expression". Then the fragment "delay 0.3" could be 
produced directly by any one of the three different non-terminal 
symbols (simple_statement, delay_alternative, 
triggering_statement). I don't think that change in the grammar 
would make any significant difference to the readability or 
parsability of Ada, so I don't see what your problem is.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20  0:47 Is it really Ok to assert that the Ada syntax is a context-free grammar ? Hibou57
  2008-02-20  2:06 ` Jeffrey R. Carter
  2008-02-20  5:53 ` Niklas Holsti
@ 2008-02-20 16:43 ` Adam Beneschan
  2 siblings, 0 replies; 31+ messages in thread
From: Adam Beneschan @ 2008-02-20 16:43 UTC (permalink / raw)


On Feb 19, 4:47 pm, Hibou57 <yannick_duch...@yahoo.fr> wrote:
> Hi peoples living here :p
>
> I got a doubt about [ARM 1.1.4-1]
>
> > The form of an Ada program is described by means of a context-free syntax together with context-dependent requirements expressed by narrative rules.
>
> But as pointed by someone, the grammar is not LR(1), due to the fact
> (which is common to many other languages), that as an exemple X(Y) can
> stand for a type cast, a function call, an array access, or even an
> array slice, and this cannot be decided without knowlegde of the
> context.
>
> Am I wrong or is there really a so big mistake in the ARM ?

Well, if this is a mistake, it is a very, very tiny one, not a big
one.  As both a user and an implementor of Ada, about the last thing I
care about is whether it fits into the definition of an LR(1) or an
LL(17) or an RLRQ(3.14159) or whatever grammar.  I just want to know
what the rules are and what my program is going to do.

As for your specific example: it's true that an <identifier>
( <expression> ) could be interpreted as an <indexed_component>,
<type_conversion>, or <function_call> according to the language
rules.  Actually, a compiler can't even necessarily tell which one it
is even if it knows the identifier and the expression, since the
identifier could be an overloaded function with one possibility being
a parameterless function (or a function with defaults for all its
parameters) that returns an array access.  But in the grand scheme of
things, that's irrelevant, because no knowledgeable implementor will
expect to just plug the grammar rules into some black box and have a
compiler automatically come out.  In practice, this probably means
that if we really wanted an LR(1) grammar, some modifications would
have to be made to the syntax rules as they're written.  But since
nobody really cares, the syntax rules as written are fine because
they're more helpful to a user of Ada than a more formally written
grammar would be.

                               -- Adam





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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 10:05   ` Martin Krischik
  2008-02-20 10:34     ` Ludovic Brenta
@ 2008-02-20 18:27     ` Jeffrey R. Carter
  2008-02-21 19:20       ` Martin Krischik
  1 sibling, 1 reply; 31+ messages in thread
From: Jeffrey R. Carter @ 2008-02-20 18:27 UTC (permalink / raw)


Martin Krischik wrote:
 >
> Not quite, if you consider "type cast" is a unchecked bit pattern copy - 
> so if you define:
> 
> function X is new Unchecked_Conversion (...);
> 
> the X would indeed be a it "type cast".

No, "type cast" is not defined for Ada. What you have described is an unchecked 
type conversion.

-- 
Jeff Carter
"English bed-wetting types."
Monty Python & the Holy Grail
15



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 15:19         ` Niklas Holsti
@ 2008-02-20 18:34           ` Hibou57 (Yannick Duchêne)
  2008-02-20 19:10             ` Hibou57 (Yannick Duchêne)
                               ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2008-02-20 18:34 UTC (permalink / raw)


On 20 fév, 16:19, Niklas Holsti <niklas.hol...@tidorum.invalid> wrote:
> rule in ARM 9.6(4). Does that make you happy? But look, the
> [...]
> parsability of Ada, so I don't see what your problem is.

Why are you so sad ? this was not in the purpose to pretend there is a
"problem" (except that I suspected an error). I was just curious
beceause I used to read that Ada and Pascal are exemples of unambigous
grammar.

As well, about LR(1), this was not to use it as a reference of
readibility, beceause the humain view of a text is not based on a
LR(1) analisys. A grammart bay be LR(1) while not redable, or the
opposite.

I was just curious and surprised, that's all.

Another exemple I've just came into :
> [ARM 4.1.4]
> attribute_designator ::=
>	identifier[(static_expression)]
>	| Access
>	| Delta
>	| Digits

Have a nice day, and lets be fairy



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 18:34           ` Hibou57 (Yannick Duchêne)
@ 2008-02-20 19:10             ` Hibou57 (Yannick Duchêne)
  2008-02-21  0:39               ` Randy Brukardt
  2008-02-20 20:22             ` Niklas Holsti
  2008-02-20 21:38             ` Manuel Collado
  2 siblings, 1 reply; 31+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2008-02-20 19:10 UTC (permalink / raw)


Just to play the fool... a bit : there is a tiny mistake at [ARM
12.4-2/2]
> formal_object_declaration ::=
>    defining_identifier_list : mode [null_exclusion] subtype_mark [:= default_expression];
>    defining_identifier_list : mode access_definition [:= default_expression];

A "|" is missing :p



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 18:34           ` Hibou57 (Yannick Duchêne)
  2008-02-20 19:10             ` Hibou57 (Yannick Duchêne)
@ 2008-02-20 20:22             ` Niklas Holsti
  2008-02-20 21:38             ` Manuel Collado
  2 siblings, 0 replies; 31+ messages in thread
From: Niklas Holsti @ 2008-02-20 20:22 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) wrote:
> On 20 f�v, 16:19, Niklas Holsti <niklas.hol...@tidorum.invalid> wrote:
> 
>>rule in ARM 9.6(4). Does that make you happy? But look, the
>>[...]
>>parsability of Ada, so I don't see what your problem is.
> 
> Why are you so sad ?

Be reassured, I don't feel sad .. I thought you did :-), but if 
that's not so, then we're both happy, good.

> I was just curious beceause I used to read that Ada and Pascal
> are exemples of unambigous grammar.

Compared to what? And what has that to do with context-freeness?

Perhaps the thing you read was about the bracketing of control 
structures, such as if-then-else-end if, where the parsing of 
nested structures was ambiguous in Algol and Pascal which do not 
have the "end if" bracket, but is unambiguous in Ada.

For sure the Ada *grammar* is ambiguous because you can 
syntactically parse some programs in many ways, for example 
programs that contain the famous fragment X(Y). The legality and 
static semantic rules are there to make all but one parse illegal, 
ensuring an unambigous meaning for the program.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 14:22       ` Hibou57
  2008-02-20 15:19         ` Niklas Holsti
@ 2008-02-20 20:51         ` Robert A Duff
  1 sibling, 0 replies; 31+ messages in thread
From: Robert A Duff @ 2008-02-20 20:51 UTC (permalink / raw)


Hibou57 <yannick_duchene@yahoo.fr> writes:

> On 20 f�v, 11:34, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
>> Jeffrey is correct; it is not a "type cast", it is a "type conversion"
>> and there is no such thing as "Ada.Unchecked_Cast". Yes, this is nit-
>> picking; why would we choose Ada if we didn't care about details and
>> wording?
>
> Ok, forgive me for the english mistake : I use either type cast or
> type conversion to mean the same thing. I will take care in the futur.

I think there's nothing wrong with using informal terms when talking
about Ada, so long as the meaning is clear from context.  For example,
I sometimes use "pointer" to mean "access type" or "access value", and I
don't see anything wrong with that.  (And some Ada folks lecture me
about it.  ;-))

The problem with "type cast" is that in the Ada context, it could mean
two different things -- a type_conversion (which is well-defined
according to the high-level semantics) or an "unchecked conversion"
(i.e. an instance of Ada.Unchecked_Conversion, which is defined
in terms of bit-level representation).  The difference is important!

> But I'm still not sure about the assertion that it is context free
> (while, Ok, the AEM does not tell it is LR(1))

The grammar given in the Ada RM under "Syntax" is a context free
grammar.  It is, however, ambiguous, and therefore not LR(1).

You noted the biggest ambiguity -- X(Y) could mean various things.
There are a few others (e.g. .all can be implicit in some cases, and
subprogram calls with no parameters don't get empty parens).  The full
power of semantic analysis is required to disambiguate these things, in
the general case.

- Bob



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 18:34           ` Hibou57 (Yannick Duchêne)
  2008-02-20 19:10             ` Hibou57 (Yannick Duchêne)
  2008-02-20 20:22             ` Niklas Holsti
@ 2008-02-20 21:38             ` Manuel Collado
  2008-02-21  0:30               ` Hibou57 (Yannick Duchêne)
  2 siblings, 1 reply; 31+ messages in thread
From: Manuel Collado @ 2008-02-20 21:38 UTC (permalink / raw)


Hibou57 (Yannick Duch�ne) escribi�:
> ... I was just curious
> beceause I used to read that Ada and Pascal are exemples of unambigous
> grammar.

Weel, the fact is that the Pascal grammar *is ambiguous*. Have you ever 
heard the term "dangling else"?

-- 
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 21:38             ` Manuel Collado
@ 2008-02-21  0:30               ` Hibou57 (Yannick Duchêne)
  0 siblings, 0 replies; 31+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2008-02-21  0:30 UTC (permalink / raw)


On 20 fév, 22:38, Manuel Collado <m.coll...@lml.ls.fi.upm.es> wrote:
> Weel, the fact is that the Pascal grammar *is ambiguous*. Have you ever
> heard the term "dangling else"?
I like to read this.... this recall some good old memories from 15
years ago :)

Yes I do, with TurbotPascal.

There was a special note in the TurboPascal intergrated help, which
said that the disambiguation was done by getting the longest construct
(as with token scaning). There was a special rule, thus this was not
considered ambigous, while for purist it was (and formaly speaking, it
was, but in practice, it was not).

Down to earth, if my memory is right, the construct

IF Cond1 THEN IF Cond2 THEN Sttm1 ELSE Sttm2;

was interpreted as

IF Cond1 THEN
BEGIN
   IF Cond2 THEN
   BEGIN
      Sttm1;
   END
   ELSE
   BEGIN
      Sttm2;
   END;
END;

instead of

IF Cond1 THEN
BEGIN
   IF Cond2 THEN
   BEGIN
      Sttm1;
   END;
END
ELSE
BEGIN
   Sttm2;
END;

It was then recommended to always use begin/end to be more explicit
and avoid bad surprises.

Of course at the begining I get some (... bad surprises). From this
time, I never leave the habitude to always use begin/end.

Ada is pleasant in this area, beceause it drop the need of a "begin"
for compound statement (single statement are treated like compound),
and the mandatory "end if" to terminate the if_statement construct
([ARM 5.3], for peoples who love formalities), will have avoid the
ambiguity.

With Ada we will have either

if Cond1 then if Cond2 then Sttm1; else Sttm2; end if; end if;

or

if Cond1 then if Cond2 then Sttm1; end if; else Sttm2; end if;

or .... a syntax error :D

Indeed, although while I came back to pascal during the past and
actual year, I did not ever more though about it, beceause it has
since this time become a provoked reflexe to me, but I must say I
"hate" this part of the Pascal syntax, and the one of Ada is really
nicer to me.

Your post Manuel, was the occasion for a nice come back into old
memories, ... so thanks to you this little moment.



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 19:10             ` Hibou57 (Yannick Duchêne)
@ 2008-02-21  0:39               ` Randy Brukardt
  2008-02-21  0:56                 ` Hibou57 (Yannick Duchêne)
  0 siblings, 1 reply; 31+ messages in thread
From: Randy Brukardt @ 2008-02-21  0:39 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

"Hibou57 (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote in message
news:2b943ca7-7b7e-4bfb-b2b5-bf2818e1e56e@t66g2000hsf.googlegroups.com...
> Just to play the fool... a bit : there is a tiny mistake at [ARM
> 12.4-2/2]
> > formal_object_declaration ::=
> >    defining_identifier_list : mode [null_exclusion] subtype_mark [:=
default_expression];
> >    defining_identifier_list : mode access_definition [:=
default_expression];
>
> A "|" is missing :p

This was previously reported.

Anyway, that's a problem only in the printed (combined) version, and not in
the actual standard. It's documented in AI05-0005-1, and will be fixed if
and when there is an updated printed version. (Note that the on-line
versions track the printed ones in order to avoid confusion.)

                           Randy.





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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21  0:39               ` Randy Brukardt
@ 2008-02-21  0:56                 ` Hibou57 (Yannick Duchêne)
  2008-02-21 22:19                   ` Randy Brukardt
  2008-02-21 22:19                   ` Randy Brukardt
  0 siblings, 2 replies; 31+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2008-02-21  0:56 UTC (permalink / raw)


On 21 fév, 01:39, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> Anyway, that's a problem only in the printed (combined) version, and not in
This is still there
-> http://www.adaic.org/standards/05rm/html/RM-12-4.html
which is linked from
-> http://www.ada-auth.org/arm.html

Do you mean there is another online source for the specification ?

If there is, I would enjoy to know the link :)



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 18:27     ` Jeffrey R. Carter
@ 2008-02-21 19:20       ` Martin Krischik
  2008-02-21 21:31         ` Jeffrey R. Carter
  0 siblings, 1 reply; 31+ messages in thread
From: Martin Krischik @ 2008-02-21 19:20 UTC (permalink / raw)


Jeffrey R. Carter wrote:

> Martin Krischik wrote:
>  >
>> Not quite, if you consider "type cast" is a unchecked bit pattern copy -
>> so if you define:
>> 
>> function X is new Unchecked_Conversion (...);
>> 
>> the X would indeed be a it "type cast".
> 
> No, "type cast" is not defined for Ada. What you have described is an
> unchecked type conversion.

"Rot" and "Rouge" are not defined in the English language either but that
does not mean the colour at the lower end of the spectrum is not defined in
English. Actually it is - it's called "Red".

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 10:34     ` Ludovic Brenta
  2008-02-20 11:13       ` Dmitry A. Kazakov
  2008-02-20 14:22       ` Hibou57
@ 2008-02-21 19:24       ` Martin Krischik
  2008-02-22 20:17         ` Simon Wright
  2008-02-23 19:02         ` Maciej Sobczak
  2 siblings, 2 replies; 31+ messages in thread
From: Martin Krischik @ 2008-02-21 19:24 UTC (permalink / raw)


Ludovic Brenta wrote:

> Martin Krischik wrote:
>> Jeffrey R. Carter schrieb:
>> > X (Y) cannot represent a type cast because Ada does not have anything
>> > called "type cast".
>>
>> Not quite, if you consider "type cast" is a unchecked bit pattern copy -
>> so if you define:
> 
> Jeffrey is correct; it is not a "type cast", it is a "type conversion"
> and there is no such thing as "Ada.Unchecked_Cast". Yes, this is nit-
> picking; why would we choose Ada if we didn't care about details and
> wording?

(X)Y copy a bit pattern.
reinterpret_cast <X>(Y) copies a bit pattern.
Unchecked_Conversion (Y) copies a bit pattern.

Just because there are three different words does not mean they are
different concepts. Just as Red, Rot and Rouge are three different words
describing the same colour.

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21 19:20       ` Martin Krischik
@ 2008-02-21 21:31         ` Jeffrey R. Carter
  0 siblings, 0 replies; 31+ messages in thread
From: Jeffrey R. Carter @ 2008-02-21 21:31 UTC (permalink / raw)


Martin Krischik wrote:
> 
> "Rot" and "Rouge" are not defined in the English language either but that
> does not mean the colour at the lower end of the spectrum is not defined in
> English. Actually it is - it's called "Red".

Aklpt!s kizzl n!lpt da.

The only language we're sure everyone on this newsgroup understands is Ada based 
on its description in the ARM. You can use any terms you like, but if they're 
not the Ada terms, expect to be misunderstood. Why exactly is it that you want 
your program to erase all your files?

-- 
Jeff Carter
"Beyond 100,000 lines of code you
should probably be coding in Ada."
P. J. Plauger
26



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21  0:56                 ` Hibou57 (Yannick Duchêne)
@ 2008-02-21 22:19                   ` Randy Brukardt
  2008-02-21 22:19                   ` Randy Brukardt
  1 sibling, 0 replies; 31+ messages in thread
From: Randy Brukardt @ 2008-02-21 22:19 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]

"Hibou57 (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote in message
news:4b75dce0-668f-48c9-9302-ff67f33bcf31@60g2000hsy.googlegroups.com...
>On 21 f�v, 01:39, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
>> Anyway, that's a problem only in the printed (combined) version, and not
in
>This is still there

Of course it is still there. It'll always be there. As I said in the
previous message:
"Note that the on-line versions track the printed ones in order to avoid
confusion."

We don't update the on-line versions (even though we could) so that people
can reference *the* current Ada standard. Otherwise, if there was a number
of different versions about, it would be very easy for people to be confused
by seeing different things when the same paragraph is referenced.

This particular problem wouldn't be a major concern, but it would hardly be
worth the (4 hour or so) effort to fix just this. And deciding what fixes
(there are more than 50 approved AIs now) to put in and which to leave out
would be a lot of effort.

The working version of the combined standard has this fixed (along with many
other things), but it is not available to the public.

> Do you mean there is another online source for the specification ?

> If there is, I would enjoy to know the link :)

There are no public links; mostly not until a formal effort to update the
standard is launched.

                              Randy Brukardt, ARG Editor





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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21  0:56                 ` Hibou57 (Yannick Duchêne)
  2008-02-21 22:19                   ` Randy Brukardt
@ 2008-02-21 22:19                   ` Randy Brukardt
  2008-02-21 23:54                     ` Hibou57 (Yannick Duchêne)
  1 sibling, 1 reply; 31+ messages in thread
From: Randy Brukardt @ 2008-02-21 22:19 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]

"Hibou57 (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote in message
news:4b75dce0-668f-48c9-9302-ff67f33bcf31@60g2000hsy.googlegroups.com...
>On 21 f�v, 01:39, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
>> Anyway, that's a problem only in the printed (combined) version, and not
in
>This is still there

Of course it is still there. It'll always be there. As I said in the
previous message:
"Note that the on-line versions track the printed ones in order to avoid
confusion."

We don't update the on-line versions (even though we could) so that people
can reference *the* current Ada standard. Otherwise, if there was a number
of different versions about, it would be very easy for people to be confused
by seeing different things when the same paragraph is referenced.

This particular problem wouldn't be a major concern, but it would hardly be
worth the (4 hour or so) effort to fix just this. And deciding what fixes
(there are more than 50 approved AIs now) to put in and which to leave out
would be a lot of effort.

The working version of the combined standard has this fixed (along with many
other things), but it is not available to the public.

> Do you mean there is another online source for the specification ?

> If there is, I would enjoy to know the link :)

There are no public links; mostly not until a formal effort to update the
standard is launched.

                              Randy Brukardt, ARG Editor





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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21 22:19                   ` Randy Brukardt
@ 2008-02-21 23:54                     ` Hibou57 (Yannick Duchêne)
  2008-02-22 19:51                       ` Randy Brukardt
  0 siblings, 1 reply; 31+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2008-02-21 23:54 UTC (permalink / raw)


On 21 fév, 23:19, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> There are no public links; mostly not until a formal effort to update the
> standard is launched.
That's good, so give a private link... with any valid user name and
any valid password... the guy does not need to know, does he/she ?
(rolling on the floor)

..... I'm curious.... I've said

(dont' hit please)



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-20 11:13       ` Dmitry A. Kazakov
@ 2008-02-22  8:57         ` Stephen Leake
  2008-02-22 10:44           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 31+ messages in thread
From: Stephen Leake @ 2008-02-22  8:57 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On Wed, 20 Feb 2008 02:34:34 -0800 (PST), Ludovic Brenta wrote:
>
>> Martin Krischik wrote:
>>> Jeffrey R. Carter schrieb:
>>>> X (Y) cannot represent a type cast because Ada does not have anything
>>>> called "type cast".
>>>
>>> Not quite, if you consider "type cast" is a unchecked bit pattern copy -
>>> so if you define:
>> 
>> Jeffrey is correct; it is not a "type cast", it is a "type conversion"
>> and there is no such thing as "Ada.Unchecked_Cast".
>
> ARM 13.7.2.

I don't see the phrase "type cast" in that section; what is your
point?

Jeffrey's point was about the specific phrase "type cast"; that is
_not_ defined by the Ada language.

-- 
-- Stephe



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-22  8:57         ` Stephen Leake
@ 2008-02-22 10:44           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 31+ messages in thread
From: Dmitry A. Kazakov @ 2008-02-22 10:44 UTC (permalink / raw)


On Fri, 22 Feb 2008 03:57:52 -0500, Stephen Leake wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> On Wed, 20 Feb 2008 02:34:34 -0800 (PST), Ludovic Brenta wrote:
>>
>>> Martin Krischik wrote:
>>>> Jeffrey R. Carter schrieb:
>>>>> X (Y) cannot represent a type cast because Ada does not have anything
>>>>> called "type cast".
>>>>
>>>> Not quite, if you consider "type cast" is a unchecked bit pattern copy -
>>>> so if you define:
>>> 
>>> Jeffrey is correct; it is not a "type cast", it is a "type conversion"
>>> and there is no such thing as "Ada.Unchecked_Cast".
>>
>> ARM 13.7.2.
> 
> I don't see the phrase "type cast" in that section; what is your
> point?

I thought it was about whether Ada has a thing semantically equivalent to
static type cast of C++, and the (true) point was that Unchecked_Conversion
could not always serve this purpose.

> Jeffrey's point was about the specific phrase "type cast"; that is
> _not_ defined by the Ada language.

Then his wording was unhappy. What X(Y) could represent is not directly
related to what Ada "has" or "calls." For example it can represent a
traffic light, tooth-powder or in fact whatever.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21 23:54                     ` Hibou57 (Yannick Duchêne)
@ 2008-02-22 19:51                       ` Randy Brukardt
  2008-02-23 18:13                         ` Hibou57 (Yannick Duchêne)
  0 siblings, 1 reply; 31+ messages in thread
From: Randy Brukardt @ 2008-02-22 19:51 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

"Hibou57 (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> wrote in message
news:4a29ee44-02b9-456b-a488-24d4f4077de4@41g2000hsc.googlegroups.com...
>On 21 f�v, 23:19, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
>> There are no public links; mostly not until a formal effort to update the
>> standard is launched.
>That's good, so give a private link... with any valid user name and
>any valid password... the guy does not need to know, does he/she ?
>(rolling on the floor)

If you found any private links, I would have to delete them. Which would
have no effect other than to make the ARG's work harder. And, yes, I do
monitor the use of any private links that may exist.

                            Randy.






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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21 19:24       ` Martin Krischik
@ 2008-02-22 20:17         ` Simon Wright
  2008-02-25 21:47           ` Samuel Tardieu
  2008-02-23 19:02         ` Maciej Sobczak
  1 sibling, 1 reply; 31+ messages in thread
From: Simon Wright @ 2008-02-22 20:17 UTC (permalink / raw)


Martin Krischik <krischik@users.sourceforge.net> writes:

> (X)Y copy a bit pattern.

  int a = 2;
  float f = (float) a;

I think you will get 2.0.

> reinterpret_cast <X>(Y) copies a bit pattern.

No idea what this does! sounds evil

> Unchecked_Conversion (Y) copies a bit pattern.

yes



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-22 19:51                       ` Randy Brukardt
@ 2008-02-23 18:13                         ` Hibou57 (Yannick Duchêne)
  0 siblings, 0 replies; 31+ messages in thread
From: Hibou57 (Yannick Duchêne) @ 2008-02-23 18:13 UTC (permalink / raw)


Hey, there is the annotated reference, and it talk about it :

in 1.1.4, it adds 14.a which says explicitly
> Discussion: {LR(1)} {ambiguous grammar} {grammar (resolution of ambiguity)} {grammar (ambiguous)} The
> grammar given in this International Standard the RM95 is not LR(1). In fact, it is ambiguous; the
> ambiguities are resolved by the overload resolution rules (see 8.6).
So it is Ok :)

Message to Randy : about the other message, I was joking of course. I
though this will seems obvious...any where, every time I'm joking,
every body think I'm serious... that's the trouble with me, I can't
joke without it to happens :(

Have a nice week-end




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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-21 19:24       ` Martin Krischik
  2008-02-22 20:17         ` Simon Wright
@ 2008-02-23 19:02         ` Maciej Sobczak
  1 sibling, 0 replies; 31+ messages in thread
From: Maciej Sobczak @ 2008-02-23 19:02 UTC (permalink / raw)


On 21 Lut, 20:24, Martin Krischik <krisc...@users.sourceforge.net>
wrote:

> (X)Y copy a bit pattern.

In Ada? No. In C or C++? Not always.

> reinterpret_cast <X>(Y) copies a bit pattern.

In C++? Not always. For example, if X is a reference type, then no
copying is involved - it is rather a "view conversion".
These conversions have ugly names for the same reasons as
Unchecked_XXX in Ada.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



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

* Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ?
  2008-02-22 20:17         ` Simon Wright
@ 2008-02-25 21:47           ` Samuel Tardieu
  0 siblings, 0 replies; 31+ messages in thread
From: Samuel Tardieu @ 2008-02-25 21:47 UTC (permalink / raw)


>>>>> "Simon" == Simon Wright <simon.j.wright@mac.com> writes:

>> reinterpret_cast <X>(Y) copies a bit pattern.

Simon> No idea what this does! sounds evil

It is an Ada.Unchecked_Conversion of Y's type into X.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



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

end of thread, other threads:[~2008-02-25 21:47 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-20  0:47 Is it really Ok to assert that the Ada syntax is a context-free grammar ? Hibou57
2008-02-20  2:06 ` Jeffrey R. Carter
2008-02-20 10:05   ` Martin Krischik
2008-02-20 10:34     ` Ludovic Brenta
2008-02-20 11:13       ` Dmitry A. Kazakov
2008-02-22  8:57         ` Stephen Leake
2008-02-22 10:44           ` Dmitry A. Kazakov
2008-02-20 14:22       ` Hibou57
2008-02-20 15:19         ` Niklas Holsti
2008-02-20 18:34           ` Hibou57 (Yannick Duchêne)
2008-02-20 19:10             ` Hibou57 (Yannick Duchêne)
2008-02-21  0:39               ` Randy Brukardt
2008-02-21  0:56                 ` Hibou57 (Yannick Duchêne)
2008-02-21 22:19                   ` Randy Brukardt
2008-02-21 22:19                   ` Randy Brukardt
2008-02-21 23:54                     ` Hibou57 (Yannick Duchêne)
2008-02-22 19:51                       ` Randy Brukardt
2008-02-23 18:13                         ` Hibou57 (Yannick Duchêne)
2008-02-20 20:22             ` Niklas Holsti
2008-02-20 21:38             ` Manuel Collado
2008-02-21  0:30               ` Hibou57 (Yannick Duchêne)
2008-02-20 20:51         ` Robert A Duff
2008-02-21 19:24       ` Martin Krischik
2008-02-22 20:17         ` Simon Wright
2008-02-25 21:47           ` Samuel Tardieu
2008-02-23 19:02         ` Maciej Sobczak
2008-02-20 18:27     ` Jeffrey R. Carter
2008-02-21 19:20       ` Martin Krischik
2008-02-21 21:31         ` Jeffrey R. Carter
2008-02-20  5:53 ` Niklas Holsti
2008-02-20 16:43 ` Adam Beneschan

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