comp.lang.ada
 help / color / mirror / Atom feed
* Getting Up to Speed - Obj.Method;
@ 2010-03-11 18:05 Warren Gay
  2010-03-11 18:16 ` Anh Vo
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Warren Gay @ 2010-03-11 18:05 UTC (permalink / raw)


I am attempting a large experiment to rewrite a project
in Ada-2005. So in the process, I am trying to get up to 
speed on some of the changes (nice to see that 
Ada.Containers made it!)

I have a tagged record, with a method:

procedure Clear(Object: in out String_Container);


Now I can call it the old way ok:

    Clear(Obj);

but with no args, trying:

    Obj.Clear();

fails to compile with:

z9.adb:65:12: missing operand

Whoops-- I just figured it out. It goes:

    Obj.Clear;

Man, that looks weird!

How do most folks feel about this new syntactic form?
It obviously had support enough to get into the std,
but I am wondering which side of the fence I am on.
Are many folks using this form?

Warren



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:05 Getting Up to Speed - Obj.Method; Warren Gay
@ 2010-03-11 18:16 ` Anh Vo
  2010-03-11 18:31   ` Simon Wright
  2010-03-11 19:01   ` Charmed Snark
  2010-03-11 18:53 ` 
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: Anh Vo @ 2010-03-11 18:16 UTC (permalink / raw)


On Mar 11, 10:05 am, Warren Gay <ve3...@gmail.com> wrote:
> I am attempting a large experiment to rewrite a project
> in Ada-2005. So in the process, I am trying to get up to
> speed on some of the changes (nice to see that
> Ada.Containers made it!)
>
> I have a tagged record, with a method:
>
> procedure Clear(Object: in out String_Container);
>
> Now I can call it the old way ok:
>
>     Clear(Obj);
>
> but with no args, trying:
>
>     Obj.Clear();
>
> fails to compile with:
>
> z9.adb:65:12: missing operand
>
> Whoops-- I just figured it out. It goes:
>
>     Obj.Clear;
>
> Man, that looks weird!
>
> How do most folks feel about this new syntactic form?
> It obviously had support enough to get into the std,
> but I am wondering which side of the fence I am on.
> Are many folks using this form?
>

Actually, I love this notation. C/C++ folks have been complaining that
Ada is too verbose and they have to type more. Now with this notation,
Ada is two character shorter than C/C++. By the way, why put a hollow
parenthesis for nothing.

Anh Vo




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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:16 ` Anh Vo
@ 2010-03-11 18:31   ` Simon Wright
  2010-03-11 18:41     ` Anh Vo
  2010-03-11 19:01   ` Charmed Snark
  1 sibling, 1 reply; 17+ messages in thread
From: Simon Wright @ 2010-03-11 18:31 UTC (permalink / raw)


Anh Vo <anhvofrcaus@gmail.com> writes:

>  By the way, why put a hollow
> parenthesis for nothing.

I often get trapped by this in Python.  foo() calls the parameterless
subprogram foo, foo is its address.



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:31   ` Simon Wright
@ 2010-03-11 18:41     ` Anh Vo
  0 siblings, 0 replies; 17+ messages in thread
From: Anh Vo @ 2010-03-11 18:41 UTC (permalink / raw)


On Mar 11, 10:31 am, Simon Wright <si...@pushface.org> wrote:
> Anh Vo <anhvofrc...@gmail.com> writes:
> >  By the way, why put a hollow
> > parenthesis for nothing.
>
> I often get trapped by this in Python.  foo() calls the parameterless
> subprogram foo, foo is its address.

It is interesting to know this for a Python newbie like me. Thank you
for your good info.



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:05 Getting Up to Speed - Obj.Method; Warren Gay
  2010-03-11 18:16 ` Anh Vo
@ 2010-03-11 18:53 ` 
  2010-03-11 19:26 ` Pascal Obry
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From:  @ 2010-03-11 18:53 UTC (permalink / raw)


Warren Gay wrote:
> Whoops-- I just figured it out. It goes:
> 
>     Obj.Clear;
> 
> Man, that looks weird!
> 
> How do most folks feel about this new syntactic form?
> It obviously had support enough to get into the std,
> but I am wondering which side of the fence I am on.
> Are many folks using this form?

I like it a lot, but then again I'm still very much a beginner when it 
comes to Ada. So I'm on the side of the fence where the above syntax is 
both used and enjoyed.  :o)

-- 
Regards,
Thomas L�cke

Email: tl at ada-dk.org
Web: http:ada-dk.org
IRC nick: ThomasLocke



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:16 ` Anh Vo
  2010-03-11 18:31   ` Simon Wright
@ 2010-03-11 19:01   ` Charmed Snark
  2010-03-11 20:09     ` Anh Vo
  1 sibling, 1 reply; 17+ messages in thread
From: Charmed Snark @ 2010-03-11 19:01 UTC (permalink / raw)


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

Anh Vo expounded in news:2801d429-d00b-46cb-955a-
f3d322b2b6ca@x1g2000prb.googlegroups.com:

> On Mar 11, 10:05�am, Warren Gay <ve3...@gmail.com> wrote:
..
>> I have a tagged record, with a method:
>>
>> procedure Clear(Object: in out String_Container);
>>
>> Now I can call it the old way ok:
>>
>> � � Clear(Obj);
>>
>> but with no args, trying:
>>
>> � � Obj.Clear();
>>
>> fails to compile with:
>>
>> z9.adb:65:12: missing operand
>>
>> Whoops-- I just figured it out. It goes:
>>
>> � � Obj.Clear;
..
> Actually, I love this notation. C/C++ folks have been complaining that
> Ada is too verbose and they have to type more. Now with this notation,
> Ada is two character shorter than C/C++. By the way, why put a hollow
> parenthesis for nothing.
> 
> Anh Vo

To me, with my heretical C background, the "()" is a strong
reminder that a method is being "called". In C/C++, the statement

     Obj.Clear;

would quietly compile clean (if Clear turned out to be a data 
member) and do nothing.

I do realize that that sort of hijinx doesn't happen around here.
But now you hopefully understand my twisted state of mind.

Don't worry-- I will assimilate.

Warren



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:05 Getting Up to Speed - Obj.Method; Warren Gay
  2010-03-11 18:16 ` Anh Vo
  2010-03-11 18:53 ` 
@ 2010-03-11 19:26 ` Pascal Obry
  2010-03-11 21:40   ` Robert A Duff
  2010-03-12  1:03   ` Adam Beneschan
  2010-03-11 21:34 ` Robert A Duff
  2010-03-12  2:55 ` John B. Matthews
  4 siblings, 2 replies; 17+ messages in thread
From: Pascal Obry @ 2010-03-11 19:26 UTC (permalink / raw)


Le 11/03/2010 19:05, Warren Gay a �crit :
> Whoops-- I just figured it out. It goes:
> 
>     Obj.Clear;
> 
> Man, that looks weird!

Well that's the same for standard procedure.

   procedure Call_Me is
   begin
    ...
   end Call_Me;

begin
   Call_Me;

You do no write:

   Call_Me();

Nothing weird for the Ada world :)

This is deliberate and was a design decision for unification of access
to variable and function returning a value:

   Is_It_Ok : Boolean;
   function Is_It_Good return Boolean;

Then, from the call side there is no distinction:

   if Is_It_Ok then

   if Is_It_Good then

It is then possible to replace access to a value by a function without
having to change the code everywhere.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 19:01   ` Charmed Snark
@ 2010-03-11 20:09     ` Anh Vo
  2010-03-12 17:51       ` Charmed Snark
  0 siblings, 1 reply; 17+ messages in thread
From: Anh Vo @ 2010-03-11 20:09 UTC (permalink / raw)


On Mar 11, 11:01 am, Charmed Snark <sn...@cogeco.ca> wrote:
> Anh Vo expounded in news:2801d429-d00b-46cb-955a-
> To me, with my heretical C background, the "()" is a strong
> reminder that a method is being "called". In C/C++, the statement
>
>      Obj.Clear;
>
> would quietly compile clean (if Clear turned out to be a data
> member) and do nothing.
>
> I do realize that that sort of hijinx doesn't happen around here.
> But now you hopefully understand my twisted state of mind.
>
> Don't worry-- I will assimilate.
>
Actually, Ada has this notation for ages specially in the tasking
area. Here is a incomplete example.
...
task type Bus_Monitor is
   entry Start;
   entry Stop;
end Bus_Monitor;
Bus_Mon_Obj : Bus_Monitor;

...
Bus_Monitor.Start;
...

Anh Vo






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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:05 Getting Up to Speed - Obj.Method; Warren Gay
                   ` (2 preceding siblings ...)
  2010-03-11 19:26 ` Pascal Obry
@ 2010-03-11 21:34 ` Robert A Duff
  2010-03-12 17:56   ` Warren
  2010-03-12  2:55 ` John B. Matthews
  4 siblings, 1 reply; 17+ messages in thread
From: Robert A Duff @ 2010-03-11 21:34 UTC (permalink / raw)


Warren Gay <ve3wwg@gmail.com> writes:

> How do most folks feel about this new syntactic form?
> It obviously had support enough to get into the std,
> but I am wondering which side of the fence I am on.
> Are many folks using this form?

As far as I can tell, most folks seem to like this new feature.
The advantage is supposedly that you don't have to worry
about where things are declared -- if you've got the
object name in your hands, you can call the methods
without horsing around with 'with' and 'use' clauses
or expanded names.

I don't much like it.  I think it's a little misleading to
imply that methods are inside the object, like components
are.  I know most OO languages do it that way.  CLOS is
a notable exception.

- Bob



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 19:26 ` Pascal Obry
@ 2010-03-11 21:40   ` Robert A Duff
  2010-03-12  0:16     ` Jeffrey R. Carter
  2010-03-12  1:03   ` Adam Beneschan
  1 sibling, 1 reply; 17+ messages in thread
From: Robert A Duff @ 2010-03-11 21:40 UTC (permalink / raw)


Pascal Obry <pascal@obry.net> writes:

> This is deliberate and was a design decision for unification of access
> to variable and function returning a value:
>
>    Is_It_Ok : Boolean;
>    function Is_It_Good return Boolean;
>
> Then, from the call side there is no distinction:
>
>    if Is_It_Ok then
>
>    if Is_It_Good then
>
> It is then possible to replace access to a value by a function without
> having to change the code everywhere.

Well, except here:

    Is_It_OK := True; -- OK
    Is_It_Good := True; -- Illegal!

;-)

I think I'd prefer the empty parens.  I'd buy the uniformity of
reference argument in a pure functional language.  But in Ada,
function calls can have side effects, whereas variable reads
cannot, so I think perhaps a syntactic distinction would be
useful.

- Bob



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 21:40   ` Robert A Duff
@ 2010-03-12  0:16     ` Jeffrey R. Carter
  0 siblings, 0 replies; 17+ messages in thread
From: Jeffrey R. Carter @ 2010-03-12  0:16 UTC (permalink / raw)


Robert A Duff wrote:
> 
> I think I'd prefer the empty parens.  I'd buy the uniformity of
> reference argument in a pure functional language.  But in Ada,
> function calls can have side effects, whereas variable reads
> cannot, so I think perhaps a syntactic distinction would be
> useful.

Ada 80 required them. They avoided some ambiguities that Ada has without them. 
They were removed in Ada 83 due to widespread dislike.

-- 
Jeff Carter
"In the frozen land of Nador they were forced to
eat Robin's minstrels, and there was much rejoicing."
Monty Python & the Holy Grail
70



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 19:26 ` Pascal Obry
  2010-03-11 21:40   ` Robert A Duff
@ 2010-03-12  1:03   ` Adam Beneschan
  2010-03-12  2:53     ` Randy Brukardt
  1 sibling, 1 reply; 17+ messages in thread
From: Adam Beneschan @ 2010-03-12  1:03 UTC (permalink / raw)


On Mar 11, 11:26 am, Pascal Obry <pas...@obry.net> wrote:
> Le 11/03/2010 19:05, Warren Gay a écrit :
>
> > Whoops-- I just figured it out. It goes:
>
> >     Obj.Clear;
>
> > Man, that looks weird!
>
> Well that's the same for standard procedure.
>
>    procedure Call_Me is
>    begin
>     ...
>    end Call_Me;
>
> begin
>    Call_Me;
>
> You do no write:
>
>    Call_Me();
>
> Nothing weird for the Ada world :)
>
> This is deliberate and was a design decision for unification of access
> to variable and function returning a value:

Really---it was a design decision?  I'm very skeptical.  I think it's
more likely that the syntax was simply inherited, ultimately from
Ada's spiritual ancestor, Algol, while C's syntax was inherited
from... ummm, I'm trying to think of some witty insult...

                                 -- Adam




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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-12  1:03   ` Adam Beneschan
@ 2010-03-12  2:53     ` Randy Brukardt
  0 siblings, 0 replies; 17+ messages in thread
From: Randy Brukardt @ 2010-03-12  2:53 UTC (permalink / raw)


"Adam Beneschan" <adam@irvine.com> wrote in message 
news:2ca3de18-a93c-4dd7-bdb7-0630f33017c6@t17g2000prg.googlegroups.com...
...
>Really---it was a design decision?  I'm very skeptical.  I think it's
>more likely that the syntax was simply inherited, ultimately from
>Ada's spiritual ancestor, Algol, while C's syntax was inherited
>from... ummm, I'm trying to think of some witty insult...

Jeff is right; Ada 80 used the "()" notation. So the fact that it doesn't 
have them now was a very intentional decision. I remember this clearly 
because our early versions of Janus/Ada used this syntax to make 
implementing expressions easy (we didn't support full overloading early 
on) -- losing the crutch was a major pain.

                                                      Randy.





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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 18:05 Getting Up to Speed - Obj.Method; Warren Gay
                   ` (3 preceding siblings ...)
  2010-03-11 21:34 ` Robert A Duff
@ 2010-03-12  2:55 ` John B. Matthews
  4 siblings, 0 replies; 17+ messages in thread
From: John B. Matthews @ 2010-03-12  2:55 UTC (permalink / raw)


In article <Xns9D388517CE320WarrensBlatherings@188.40.43.245>,
 Warren Gay <ve3wwg@gmail.com> wrote:

[...]
> How do most folks feel about this new syntactic form?
> It obviously had support enough to get into the std,
> but I am wondering which side of the fence I am on.
> Are many folks using this form?

I'm a fan of new prefixed notation. Here's an example that implements 
two related algorithms, one using Ada 2005 Containers and one using Ada 
95:

<http://home.roadrunner.com/~jbmatthews/jumble.html>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 20:09     ` Anh Vo
@ 2010-03-12 17:51       ` Charmed Snark
  0 siblings, 0 replies; 17+ messages in thread
From: Charmed Snark @ 2010-03-12 17:51 UTC (permalink / raw)


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

Anh Vo expounded in news:6683b9ad-02d6-4ee3-bf3a-
b19bc55d0f7e@z10g2000prh.googlegroups.com:

> On Mar 11, 11:01�am, Charmed Snark <sn...@cogeco.ca> wrote:
>> Anh Vo expounded in news:2801d429-d00b-46cb-955a-
>> To me, with my heretical C background, the "()" is a strong
>> reminder that a method is being "called". In C/C++, the statement
>>
>> � � �Obj.Clear;
>>
> Actually, Ada has this notation for ages specially in the tasking
> area. Here is a incomplete example.
> ...
> task type Bus_Monitor is
>    entry Start;
>    entry Stop;
> end Bus_Monitor;
> Bus_Mon_Obj : Bus_Monitor;
> 
> ...
> Bus_Monitor.Start;
> ...
> 
> Anh Vo

Yes, I remember that now.



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-11 21:34 ` Robert A Duff
@ 2010-03-12 17:56   ` Warren
  2010-03-12 18:14     ` Jeffrey R. Carter
  0 siblings, 1 reply; 17+ messages in thread
From: Warren @ 2010-03-12 17:56 UTC (permalink / raw)


Robert A Duff expounded in news:wccpr3apmox.fsf@shell01.TheWorld.com:

> Warren Gay <ve3wwg@gmail.com> writes:
> 
>> How do most folks feel about this new syntactic form?
>> It obviously had support enough to get into the std,
>> but I am wondering which side of the fence I am on.
>> Are many folks using this form?
> 
> As far as I can tell, most folks seem to like this new feature.
> The advantage is supposedly that you don't have to worry
> about where things are declared -- if you've got the
> object name in your hands, you can call the methods
> without horsing around with 'with' and 'use' clauses
> or expanded names.

Yes, that was one thing that did appeal to me.

Warren



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

* Re: Getting Up to Speed - Obj.Method;
  2010-03-12 17:56   ` Warren
@ 2010-03-12 18:14     ` Jeffrey R. Carter
  0 siblings, 0 replies; 17+ messages in thread
From: Jeffrey R. Carter @ 2010-03-12 18:14 UTC (permalink / raw)


Warren wrote:
> Robert A Duff expounded in news:wccpr3apmox.fsf@shell01.TheWorld.com:
> 
>> As far as I can tell, most folks seem to like this new feature.
>> The advantage is supposedly that you don't have to worry
>> about where things are declared -- if you've got the
>> object name in your hands, you can call the methods
>> without horsing around with 'with' and 'use' clauses
>> or expanded names.
> 
> Yes, that was one thing that did appeal to me.

One thing I noticed about the use of the PragmAda Reusable Components is that 
people like to use the protected forms, even for sequential purposes, for this 
very reason.

-- 
Jeff Carter
"What I wouldn't give for a large sock with horse manure in it."
Annie Hall
42



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

end of thread, other threads:[~2010-03-12 18:14 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-11 18:05 Getting Up to Speed - Obj.Method; Warren Gay
2010-03-11 18:16 ` Anh Vo
2010-03-11 18:31   ` Simon Wright
2010-03-11 18:41     ` Anh Vo
2010-03-11 19:01   ` Charmed Snark
2010-03-11 20:09     ` Anh Vo
2010-03-12 17:51       ` Charmed Snark
2010-03-11 18:53 ` 
2010-03-11 19:26 ` Pascal Obry
2010-03-11 21:40   ` Robert A Duff
2010-03-12  0:16     ` Jeffrey R. Carter
2010-03-12  1:03   ` Adam Beneschan
2010-03-12  2:53     ` Randy Brukardt
2010-03-11 21:34 ` Robert A Duff
2010-03-12 17:56   ` Warren
2010-03-12 18:14     ` Jeffrey R. Carter
2010-03-12  2:55 ` John B. Matthews

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