* Operator question.
@ 2002-02-14 16:22 Wannabe h4x0r
2002-02-14 16:55 ` Martin Dowie
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wannabe h4x0r @ 2002-02-14 16:22 UTC (permalink / raw)
Alright, forgive me if this question seems dumb. I cant beleive I havent
asked it before now.(or maybe I have and I just forgot.)
What does the operator '=>' mean? I've been looking through my book
"Programming in Ada95" but I cant seem to find it anywhere.
I see it everywhere in Ada code. Maybe I'm just a slow learner.
Any help would be appreciated.
Thanks.
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Operator question.
2002-02-14 16:22 Wannabe h4x0r
@ 2002-02-14 16:55 ` Martin Dowie
2002-02-14 19:56 ` Jerry Petrey
2002-02-14 21:26 ` Stephen Leake
2 siblings, 0 replies; 5+ messages in thread
From: Martin Dowie @ 2002-02-14 16:55 UTC (permalink / raw)
"Wannabe h4x0r" <chris@dont.spam.me> wrote in message
news:2vRa8.11975$kt5.28657@rwcrnsc52.ops.asp.att.net...
> Alright, forgive me if this question seems dumb. I cant beleive I havent
> asked it before now.(or maybe I have and I just forgot.)
>
> What does the operator '=>' mean? I've been looking through my book
> "Programming in Ada95" but I cant seem to find it anywhere.
>
> I see it everywhere in Ada code. Maybe I'm just a slow learner.
Me too ;-)
'=>' is use in a number of places, but really just to get a nice
readable syntax - it has no hidden value itself:
1. In named association e.g. the procedure call:
Foo (Value => Bar);
'Value' is the 'formal parameter name', 'Bar' is the 'actual parameter'
2. In case statements:
case Value is
when Foo =>
...
end case;
3. In array assignment:
Value : Array_Type := (1 .. 10 => 0);
4. In exception handlers:
begin
...
exception
when My_Exception =>
...
end;
There are probably others which I can't think of off the top of my
head.
Hope this helps.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Operator question.
2002-02-14 16:22 Wannabe h4x0r
2002-02-14 16:55 ` Martin Dowie
@ 2002-02-14 19:56 ` Jerry Petrey
2002-02-14 21:26 ` Stephen Leake
2 siblings, 0 replies; 5+ messages in thread
From: Jerry Petrey @ 2002-02-14 19:56 UTC (permalink / raw)
Wannabe h4x0r wrote:
>
> Alright, forgive me if this question seems dumb. I cant beleive I havent
> asked it before now.(or maybe I have and I just forgot.)
>
> What does the operator '=>' mean? I've been looking through my book
> "Programming in Ada95" but I cant seem to find it anywhere.
>
> I see it everywhere in Ada code. Maybe I'm just a slow learner.
>
> Any help would be appreciated.
>
> Thanks.
>
> Chris
Actually Barnes first mentions the => (commonly called 'arrow') in his
section on array aggregates - he says it is akin to the 'pointing hand'
sign found in old railway timetables and used for indication directions.
Normally => is thought of as meaning 'gets' or 'becomes' as in the
subprogram call Foo (Value => X). The formal parameter Value 'gets'
the actual parameter X and so forth. In the case structure, it takes
on the 'pointing hand' analogy even better, i.e. 'for this case do this'.
Jerry
--
-----------------------------------------------------------------------------
-- Jerry Petrey
-- Senior Principal Systems Engineer - Navigation, Guidance, & Control
-- Raytheon Missile Systems - Member Team Ada & Team Forth
-- NOTE: please remove <NOSPAM> in email address to reply
-----------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Operator question.
2002-02-14 16:22 Wannabe h4x0r
2002-02-14 16:55 ` Martin Dowie
2002-02-14 19:56 ` Jerry Petrey
@ 2002-02-14 21:26 ` Stephen Leake
2 siblings, 0 replies; 5+ messages in thread
From: Stephen Leake @ 2002-02-14 21:26 UTC (permalink / raw)
Wannabe h4x0r <chris@dont.spam.me> writes:
> Alright, forgive me if this question seems dumb. I cant beleive I havent
> asked it before now.(or maybe I have and I just forgot.)
>
> What does the operator '=>' mean? I've been looking through my book
> "Programming in Ada95" but I cant seem to find it anywhere.
Strictly speaking, "=>" is not an operator; it does not specify an
action performed on parameters, like "+" and "*" do. This may seem
like a nit, but it is very helpful to use correct terminology.
LRM 2.2 (14) says "=>" is called "arrow".
It is used for named association; it "associates" a parameter name
with the actual value in a subprogram call. For example:
procedure Foo (First, Last : in Integer);
Foo (First => 1, Last => 2);
This means the parameter 'First' gets the value 1, and 'Last' gets the
value 2. People often read "=>" as "gets".
Named association is also used in aggregates for records and arrays.
--
-- Stephe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Operator question.
@ 2002-02-15 6:03 Christoph Grein
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Grein @ 2002-02-15 6:03 UTC (permalink / raw)
> What does the operator '=>' mean? I've been looking through my book
> "Programming in Ada95" but I cant seem to find it anywhere.
Just an addition to Martin Dowie's and Stephen Leake's explanation:
'=>' is not an operator, it is a delimiter (RM 2.2).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-02-15 6:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-15 6:03 Operator question Christoph Grein
-- strict thread matches above, loose matches on Subject: below --
2002-02-14 16:22 Wannabe h4x0r
2002-02-14 16:55 ` Martin Dowie
2002-02-14 19:56 ` Jerry Petrey
2002-02-14 21:26 ` Stephen Leake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox