473,805 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Teaching new tricks to an old dog (C++ -->Ada)

I 'm following various posting in "comp.lang. ada, comp.lang.c++ ,
comp.realtime, comp.software-eng" groups regarding selection of a
programming language of C, C++ or Ada for safety critical real-time
applications. The majority of expert/people recommend Ada for safety
critical real-time applications. I've many years of experience in C/C++ (and
Delphi) but no Ada knowledge.

May I ask if it is too difficult to move from C/C++ to Ada?
What is the best way of learning Ada for a C/C++ programmer?

Jul 23 '05
822 29868
Wes Groleau wrote:
That is the approach perl takes to multiple inheritance. At least
I think so--I haven't finished studying it. What does C++ or Eiffel
do when multiple inheritance creates two meanings for the same name?

What do you mean by two meanings?

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #631
On 23 Mar 2005 18:16:42 -0800, Jerry Coffin <jc*****@taeus. com> wrote:
Sorry, but if you think a class is called a tagged record in Ada,
you don't understand the language.

I'll openly admit that my knowledge of Ada 95 is _extremely_ limited
(I'm afraid I quit using Ada before 1995). Perhaps I need to take
another look in this area.
OTOH, doing a bit more looking, if I've misunderstood the situation, at
least I have some company. For example:

This is just a matter of simile. A tagged type and derivatives of tagged
types provide dispatching and other typical OOP facilities. Where the
concept differs from the class concept is that visibility is orthogonal,
provided by packages and other more traditional Ada facilities, while the
class concept combines the two.

- Ed
Jul 23 '05 #632
Ioannis Vranos wrote:
Wes Groleau wrote:
That is the approach perl takes to multiple inheritance. At least
I think so--I haven't finished studying it. What does C++ or Eiffel
do when multiple inheritance creates two meanings for the same name?


What do you mean by two meanings?


Class Wagon has method Draw.
Class Picture has method Draw.

If you multiply inherit to make
Class Picture_Of_A_Wa gon, what does the method Draw do?

This was one of the arguments against having multiple
inheritance. But I think it's a silly argument. One
could just as logically argue that the "use" clause
should not exist because two packages might have Draw
subprograms. Or that overloading should not be allowed
because it's possible to write something ambiguous.

Ada's answer for the former is that if and only if the
situation _actually_ arises, neither of the choices is visible.

For the latter, the code just won't compile.

--
Wes Groleau

"There ain't nothin' in this world that's worth being a snot over."
-- Larry Wall
Jul 23 '05 #633
On Wed, 23 Mar 2005 21:42:58 -0500, Wes Groleau
<gr**********@f reeshell.org> wrote:
That is the approach perl takes to multiple inheritance. At least
I think so--I haven't finished studying it. What does C++ or Eiffel
do when multiple inheritance creates two meanings for the same name?

Eiffel has very nice and elegant facilities for resolving ambiguities. A
lot of thought went into the situation of "diamond inheritance", where an
ultimate base class is inherited via two distinct ancestors, and how to
resolve it. Eiffel is in many ways Ada's beautiful niece. But Ada is a
lot more portable.

- Ed
Jul 23 '05 #634
Jim Rogers wrote:
My reading of the information at that url indicates that GMP allows
the specification of precision, but not the specification of a limited
range of valid values.


Since I have had enough with this signed value range of Ada, here is a
quick implementation of mine and some uses of it.

I am sure one can create a better one or a container directly that
supports ranges, if he devotes some time, so the question again arises,
since it is possible and nothing exists, probably it is not considered
useful to have such a feature in C++:
#include <vector>
#include <algorithm>
#include <cstdlib>

template <class T>
class range
{
std::vector<T> array;
T min, max;

public:
range(const T &mi, const T &ma):array(m a-mi+1), min(mi), max(ma)
{
using namespace std;

if(max-min<=0)
;//throw some exception

for(typename vector<T>::size _type i=0; i<array.size() ; ++i)
array[i]=min+i;
}

const T &operator[](const T &index)
{
// Add range checking max>=index>=min if desirable

return array[index-min+1];
}

operator T() { return array.size(); }

};
int main()
{
using namespace std;

range<int> r(-100, -20);

vector<int> vec(r);

vec[r[-65]]=3;
}


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #635
Ioannis Vranos wrote:

Jim Rogers wrote:
My reading of the information at that url indicates that GMP allows
the specification of precision, but not the specification of a limited
range of valid values.

Since I have had enough with this signed value range of Ada, here is a
quick implementation of mine and some uses of it.

I am sure one can create a better one or a container directly that
supports ranges, if he devotes some time, so the question again arises,
since it is possible and nothing exists, probably it is not considered
useful to have such a feature in C++:
#include <vector>
#include <algorithm>
#include <cstdlib>

template <class T>
class range
{
std::vector<T> array;
T min, max;

public:
range(const T &mi, const T &ma):array(m a-mi+1), min(mi), max(ma)
{
using namespace std;

if(max-min<=0)
;//throw some exception

for(typename vector<T>::size _type i=0; i<array.size() ; ++i)
array[i]=min+i;
}

const T &operator[](const T &index)
{
// Add range checking max>=index>=min if desirable


fixed: return array[index-min]; }

operator T() { return array.size(); }

};
int main()
{
using namespace std;

range<int> r(-100, -20);

vector<int> vec(r);

vec[r[-65]]=3;
}

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #636
Jim Rogers wrote:

[ ... ]
For instance the following macro can cause some serious problems when
mis-applied:

#define SWAP(A,B) ((temp) = (A);(A) = (B); (B) = (temp))

char s1[30];
int i;

SWAP(S1, i);

In many cases it is safer to define an in-line function than to
define a macro.


I don't see a particularly serious problem here -- the code simply
won't compile. At the moment you have some syntactical problems and
sloppiness that's overlooked by Ada comilers (because Ada is
case-insensitive).

Even ignoring those, however, it will fail because of a
type-difference. To give a concrete example, after (partially) fixing
your code above, Visual C++ says:

swap.cpp(7) : error C2440: '=' : cannot convert from 'int' to 'char
[30]'
There are no conversions to array types, although there are
conversions to references or pointers to arrays

Modulo trivial things like ':=' vs. '=', 'int' vs. 'Integer', etc., I
suspect that's on the same general order as you'd expect to see from an
Ada compiler given code that attempted to assign an Integer to an array
of characters.

I think most C++ programmers, however, would tend to agree that in this
case you'd generally be better off using std::swap.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Jul 23 '05 #637
Wes Groleau wrote:
Class Wagon has method Draw.
Class Picture has method Draw.

If you multiply inherit to make
Class Picture_Of_A_Wa gon, what does the method Draw do?

In C++ you will get an error message until you define a newer version of
Draw for Picture_Of_A_Wa gon class.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #638
Ioannis Vranos wrote:

fixed: return array[index-min];


See? This is when proper language support comes in handy.
Georg
Jul 23 '05 #639
Ioannis Vranos wrote:
Jim Rogers wrote:
My reading of the information at that url indicates that GMP allows
the specification of precision, but not the specification of a limited
range of valid values.

Jim doesn't mention fpt ranges in the context of arrays.
Just a floating point type whose values range between 0.0 and 1.0.
And a description of the use of this type that has a range constraint.
No arrays or signs in sight.

Since I have had enough with this signed value range of Ada,


Forget about the sign, as you did in your code with min and max.
This is not a sign issue. This isn't limited to array bounds
checking. It has to do with types and with values that match at compile
time.
For a start, add a template parameter to class range from which
the compiler can infer the min and max values.
Jul 23 '05 #640

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2366
by: Mediocre Person | last post by:
Well, after years of teaching grade 12 students c++, I've decided to make a switch to Python. Why? * interactive mode for learning * less fussing with edit - compile - link - run - debug - edit - compile - link - run -..... * lots of modules * I was getting tired of teaching c++! Bored teacher = bad instruction.
14
1828
by: Gabriel Zachmann | last post by:
This post is not strictly Python-specific, still I would like to learn other university teachers' opinion. Currently, I'm teaching "introduction to OO programming" at the undergrad level. My syllabus this semester consists of a bit of Python (as an example of a scripting language) and C++ (as an example of a compiled language). With C++, I go all the way up to meta-programming. My question now is: do you think I should switch over to...
3
1538
by: andy_irl | last post by:
Hi there I have been asked to teach HTML to a group in our local village community. It is nothing too serious, just a community development grant aided scheme. It will be a 10 week course of two hours per week and will mainly consist of mature students. I may or may not include GUI's depending if I can fit it all in to the time allocated. I was wondering if anyone could point me to any useful teaching resources for HTML on the web ie...
12
2004
by: Pierre Senellart | last post by:
I am going to teach a basic Web design course (fundamentals of HTML/CSS, plus some basic client-side (JavaScript) and server-side (PHP, perhaps XSLT) scripting). Most of the students do not have any previous knowledge of all of this. I am strongly considering teaching XHTML 1.0 Strict instead of HTML 4.01 strict, for the following reasons: - XML syntax is far more simple to teach than HTML/SGML, simply because there are not as many...
16
4379
by: msnews.microsoft.com | last post by:
I am teaching C# to my 11 year old child. One challenge is that all the C# books I own and that I have seen in bookstores are full of language that is not easily comprehended by a student at that age. Can anyone recommend books (or perhaps websites) tuned for younger audiences? BTW, its amazing how fast a student can absorb this kind of information at that age. Lucky them! Thanks, Bruce
24
2867
by: Richard Aubin | last post by:
I'm really new to vb.net programming and programming in general. I would like to teach myself on how to program effectively and I have the financial and time resources to do so. Can I anyone recommend and point me in the right direction where I should start? -- Richard Aubin
0
1720
by: e.expelliarmus | last post by:
check this out buddies. kool website for: * hacking and anti hacking tricks * anti hackng tricks. * registry tweaks * orkut tricks * small virus * computer tricks and loads of different tricks... www.realm-of-tricks.blogspot.com www.registrydecoded.blogspot.com
1
3897
by: JosAH | last post by:
Greetings, Introduction This week's tip describes a few old tricks that are almost forgotten by most people around here. Sometimes there's no need for these tricks anymore because processors nowadays are so fast and memory comes in abundance. But still, if we implement an algorithm that is better, or more efficient, than another one, those faster processors run the first algorithm faster than the other one. If an algorithm takes less...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.