comp.lang.ada
 help / color / mirror / Atom feed
* Package Question [Newbie]
@ 2001-07-06  7:06 JM
  2001-07-06 10:59 ` Package Question [Newbie] (in C++ terms) Larry Kilgallen
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: JM @ 2001-07-06  7:06 UTC (permalink / raw)


Hi,

I'm still very green wrt to Ada but after looking at few tutorials a
have a couple of quick questions/observations. My background is C++ so
I'm grasping for commonalities.

1. It  looks as though basically the package is a class?

2.  And from a C++ point of view the package procedures are static
functions that operate on references to the package? So basically
'this' doesn't exist?

Thanks,
Jason



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

* Re: Package Question [Newbie] (in C++ terms)
  2001-07-06  7:06 Package Question [Newbie] JM
@ 2001-07-06 10:59 ` Larry Kilgallen
  2001-07-06 12:54 ` Package Question [Newbie] Marc A. Criley
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Larry Kilgallen @ 2001-07-06 10:59 UTC (permalink / raw)


In article <ssoakt067vi6drpdjatvp23qjqm94a7gak@4ax.com>, JM <jmillard1@homey_remove_y.com> writes:
> Hi,
> 
> I'm still very green wrt to Ada but after looking at few tutorials a
> have a couple of quick questions/observations. My background is C++ so
> I'm grasping for commonalities.

In general, you are ill-served to compare these two languages while
trying to learn one of them.  It is better if you learn the second
language without reference to the first.  When you have become
proficient in the second, you may choose to make comparisons with
the first (or not).

> 1. It  looks as though basically the package is a class?

No, packages are independent of classes (but not vice versa).  Try
learning a bit about packages from a non-object-oriented viewpoint,
and when you have that down add object orientation to the mix.

> 2.  And from a C++ point of view the package procedures are static
> functions that operate on references to the package? So basically
> 'this' doesn't exist?

You will do better in this newsgroup (and learning Ada in general)
to pose questions in absolute terms rather than in terms of C++.

If you are still burning with curiousity, a page called:

	The C++ To Ada Translation Page 

is among those listed at:

	http://www.adapower.com/articles/

I have great respect for the author of the page, but I don't give
the direct URL, because at this point if there is one URL you need
to keep in mind it is the AdaPower site.



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

* Re: Package Question [Newbie]
  2001-07-06  7:06 Package Question [Newbie] JM
  2001-07-06 10:59 ` Package Question [Newbie] (in C++ terms) Larry Kilgallen
@ 2001-07-06 12:54 ` Marc A. Criley
  2001-07-06 13:49 ` Ted Dennison
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marc A. Criley @ 2001-07-06 12:54 UTC (permalink / raw)


JM wrote:
> 
> Hi,
> 
> I'm still very green wrt to Ada but after looking at few tutorials a
> have a couple of quick questions/observations. My background is C++ so
> I'm grasping for commonalities.
> 
> 1. It  looks as though basically the package is a class?
> 
> 2.  And from a C++ point of view the package procedures are static
> functions that operate on references to the package? So basically
> 'this' doesn't exist?

A book written to aid those experienced with C and C++ in transitioning
to Ada 95 is "Ada 95 for C and C++ Programmers" by Simon Johnston.  ISBN
0-201-40363-3.

Marc A. Criley
Senior Staff Engineer
Quadrus Corporation
www.quadruscorp.com



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

* Re: Package Question [Newbie]
  2001-07-06  7:06 Package Question [Newbie] JM
  2001-07-06 10:59 ` Package Question [Newbie] (in C++ terms) Larry Kilgallen
  2001-07-06 12:54 ` Package Question [Newbie] Marc A. Criley
@ 2001-07-06 13:49 ` Ted Dennison
  2001-07-06 13:54 ` DuckE
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ted Dennison @ 2001-07-06 13:49 UTC (permalink / raw)


In article <ssoakt067vi6drpdjatvp23qjqm94a7gak@4ax.com>, JM says...
>I'm still very green wrt to Ada but after looking at few tutorials a
>have a couple of quick questions/observations. My background is C++ so
>I'm grasping for commonalities.
>
>1. It  looks as though basically the package is a class?

No. The closest analog in C++ is the "namespace" feature.

The closest analog Ada has for a C++ class is a tagged type inside a package
(you need both).

>2.  And from a C++ point of view the package procedures are static
>functions that operate on references to the package? So basically
>'this' doesn't exist?

No. Probably the best analogy is to a (non class-based) function inside a
namespace.

It is true however, that "this" doesn't exist. When you are calling dispatching
operations in Ada, the object that is dispatched on (actually, there can be more
than one), is passed in just like any other parameter. If it makes you
comfortable, you could always name the parameter "This". :-)


It would probably be best to forget about C++ while you are learning Ada. There
are some situations where you will find parallels, but it will mostly just
mislead you. This is particularly the case with string handling, because Ada's
string philosophy is *very* different from C's. I think Ada's way is more
powerful (and certianly faster). But people who insist on using Ada strings the
C way get very frustrated.


---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



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

* Re: Package Question [Newbie]
  2001-07-06  7:06 Package Question [Newbie] JM
                   ` (2 preceding siblings ...)
  2001-07-06 13:49 ` Ted Dennison
@ 2001-07-06 13:54 ` DuckE
  2001-07-06 14:13 ` Marin David Condic
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: DuckE @ 2001-07-06 13:54 UTC (permalink / raw)



"JM" <jmillard1@homey_remove_y.com> wrote in message
news:ssoakt067vi6drpdjatvp23qjqm94a7gak@4ax.com...
> Hi,
>
> I'm still very green wrt to Ada but after looking at few tutorials a
> have a couple of quick questions/observations. My background is C++ so
> I'm grasping for commonalities.
>
> 1. It  looks as though basically the package is a class?

Not really.  If you want to draw a parallel, I think a package is more like
a C++ namespace (although I don't know namespaces that well).

The "tagged type" in Ada is similar to C++ classes, but in Ada the "this"
pointer is explicit.

SteveD

> 2.  And from a C++ point of view the package procedures are static
> functions that operate on references to the package? So basically
> 'this' doesn't exist?
>
> Thanks,
> Jason





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

* Re: Package Question [Newbie]
  2001-07-06  7:06 Package Question [Newbie] JM
                   ` (3 preceding siblings ...)
  2001-07-06 13:54 ` DuckE
@ 2001-07-06 14:13 ` Marin David Condic
  2001-07-06 15:42 ` JM
  2001-07-10  0:23 ` Keith Thompson
  6 siblings, 0 replies; 8+ messages in thread
From: Marin David Condic @ 2001-07-06 14:13 UTC (permalink / raw)


You can use packages to create classes, but the two are not exactly
synonimous. Packages will do a lot more than just build classes.

The "this" thing in C++ is sort of a kludge (IMHO) because everything in C++
wants to be a kind of binary operator function. (the syntax and semantics of
all this are insane!) Really, you are better off not trying to find
analogies to C++ in Ada because the concepts of how a language should work
are very different. If you want to do OOP in Ada, learn about tagged types
and subprograms within packages and you'll be well on your way.

Look at http://www.adapower.org/ for all sorts of resources to help you
learn Ada. This newsgroup will be very helpful to you as well.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"JM" <jmillard1@homey_remove_y.com> wrote in message
news:ssoakt067vi6drpdjatvp23qjqm94a7gak@4ax.com...
> Hi,
>
> I'm still very green wrt to Ada but after looking at few tutorials a
> have a couple of quick questions/observations. My background is C++ so
> I'm grasping for commonalities.
>
> 1. It  looks as though basically the package is a class?
>
> 2.  And from a C++ point of view the package procedures are static
> functions that operate on references to the package? So basically
> 'this' doesn't exist?
>
> Thanks,
> Jason





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

* Re: Package Question [Newbie]
  2001-07-06  7:06 Package Question [Newbie] JM
                   ` (4 preceding siblings ...)
  2001-07-06 14:13 ` Marin David Condic
@ 2001-07-06 15:42 ` JM
  2001-07-10  0:23 ` Keith Thompson
  6 siblings, 0 replies; 8+ messages in thread
From: JM @ 2001-07-06 15:42 UTC (permalink / raw)


On Fri, 06 Jul 2001 07:06:19 GMT, JM <jmillard1@homey_remove_y.com>
wrote:

[Snip self]

Great! I think I've got it. Thanks again for all your helpful
comments.

Regards,
Jason



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

* Re: Package Question [Newbie]
  2001-07-06  7:06 Package Question [Newbie] JM
                   ` (5 preceding siblings ...)
  2001-07-06 15:42 ` JM
@ 2001-07-10  0:23 ` Keith Thompson
  6 siblings, 0 replies; 8+ messages in thread
From: Keith Thompson @ 2001-07-10  0:23 UTC (permalink / raw)


JM <jmillard1@homey_remove_y.com> writes:
> Hi,
> 
> I'm still very green wrt to Ada but after looking at few tutorials a
> have a couple of quick questions/observations. My background is C++ so
> I'm grasping for commonalities.
> 
> 1. It  looks as though basically the package is a class?

Not quite.  In C++, a class is both a unit of encapsulation (a module)
and a data type.  Ada separates these concepts.  A package is a
module, but it's not a data type, (though you can declare data types
within it); it's similar to a C++ namespace.  A record type is like a
C++ struct; a tagged type is like a class.

The closest Ada equivalent to a class is probably a package declaring
a single tagged type and the operations on it, but Ada packages
provide more flexibility.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
Cxiuj via bazo apartenas ni.



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

end of thread, other threads:[~2001-07-10  0:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-06  7:06 Package Question [Newbie] JM
2001-07-06 10:59 ` Package Question [Newbie] (in C++ terms) Larry Kilgallen
2001-07-06 12:54 ` Package Question [Newbie] Marc A. Criley
2001-07-06 13:49 ` Ted Dennison
2001-07-06 13:54 ` DuckE
2001-07-06 14:13 ` Marin David Condic
2001-07-06 15:42 ` JM
2001-07-10  0:23 ` Keith Thompson

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