Discussion:
urgent question - generics
(too old to reply)
s***@gmail.com
2007-09-03 08:47:29 UTC
Permalink
I need your urgent help, I have an exam soon, and I still cant figure
this out:
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.

Do you have any ideas?
Thanks a lot.
R
Pascal Obry
2007-09-03 09:14:37 UTC
Permalink
Post by s***@gmail.com
Do you have any ideas?
Yep, read your lesson :)

Sorry but this is really a trivial question, you must have seen this at
some point!

Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
s***@gmail.com
2007-09-03 09:28:10 UTC
Permalink
Dmitry A. Kazakov
2007-09-03 09:58:19 UTC
Permalink
I'm trying to find the answer for 2 days. I've been studying the
language my self from the books, perhaps there is something that I'm
missing.
You'd find much more understanding here if you have presented the results
of your 2-days research, like code snippets, ideas etc. There is a long
standing tradition in comp.lang.ada not to answer to exam/homework
question.

A hint. The answer to your question is given as an example in the Ada
language reference manual, section 12. I hope the subsection (there are 8
of them) you will be able to locate by yourself.

Good luck,
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
s***@gmail.com
2007-09-03 10:19:06 UTC
Permalink
Post by Dmitry A. Kazakov
I'm trying to find the answer for 2 days. I've been studying the
language my self from the books, perhaps there is something that I'm
missing.
You'd find much more understanding here if you have presented the results
of your 2-days research, like code snippets, ideas etc. There is a long
standing tradition in comp.lang.ada not to answer to exam/homework
question.
A hint. The answer to your question is given as an example in the Ada
language reference manual, section 12. I hope the subsection (there are 8
of them) you will be able to locate by yourself.
Good luck,
--
Regards,
Dmitry A. Kazakovhttp://www.dmitry-kazakov.de
Spasiba Dmitry,
I will look into that.
I am not familiar with this group, and I simply tried to ask an
annoying question, because I've realized it's a basic issue, yet I
could not figure it out.
I hope I will understand it aventually.
Thanks a lot!
Pascal Obry
2007-09-03 13:41:58 UTC
Permalink
So, perhaps you think you are very clever, but you don't know me, and
you don't know if I'm lazy or not. So if you don't want to help, then
just don't and keep your smart remarks to your self.
Sorry it was not my intent. As others have said it, it is a long
tradition on comp.lang.ada to help when technical informations or
"proof" of actual research is given. The answer to most of us in cla is
trivial so it is hard to tell that it was not by laziness that it was
not understood :)
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.
generic
procedure Proc;
function Func (P1 : in Positive) return String;

Now frankly I can't figure out what would be the point of Proc as it
won't be able to access/use Func parameters (kind of callback to update
something maybe...). But if this is the actual question you got the answer.

Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Niklas Holsti
2007-09-03 14:08:28 UTC
Permalink
Post by s***@gmail.com
..
Post by s***@gmail.com
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.
generic
procedure Proc;
I assume Pascal meant "with procedure Proc;" here.
Post by s***@gmail.com
function Func (P1 : in Positive) return String;
It's still unclear to me if the OP wants the parameterless
procedure (Proc, above) to be a generic parameter (as in Pascal's
solution) that is associated with an actual procedure when the
generic function is instantiated, or a non-generic parameter to the
(generic) function that is associated with an actual procedure when
an instance of the generic function is called (as in "anon's"
non-generic solution where only the address of the procedure was used).
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
Pascal Obry
2007-09-03 14:44:09 UTC
Permalink
Post by Niklas Holsti
Post by s***@gmail.com
generic
procedure Proc;
I assume Pascal meant "with procedure Proc;" here.
Yes, of course !

Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Dmitry A. Kazakov
2007-09-03 15:01:14 UTC
Permalink
Post by Niklas Holsti
It's still unclear to me if the OP wants the parameterless
procedure (Proc, above) to be a generic parameter (as in Pascal's
solution) that is associated with an actual procedure when the
generic function is instantiated, or a non-generic parameter to the
(generic) function that is associated with an actual procedure when
an instance of the generic function is called (as in "anon's"
non-generic solution where only the address of the procedure was used).
I doubt that the exercise would use the word "generic" in this case. Just:

function Bar (...; Foo : access procedure) return ...; -- Ada 2005

type Foo_Ptr is access procedure;
function Bar (...; Foo : Foo_Ptr) return ...; -- Ada 95

But OK, in order to add a bit more confusion (:-)), there also could be a
generic function which formal generic parameter is an instance of a generic
parameterless procedure. Here it goes:

generic
...
package I_Have_A_Foo is -- We need an envelope package
procedure Foo;
end I_Have_A_Foo;

generic
with package Here_Is_My_Foo is new I_Have_A_Foo (<>);
function Bar (...) return ...;

Moreover, there could be a generic function which formal generic parameter
is inherited from a generic ancestor:

generic
with procedure Foo;
package I_Take_Foo is ... end I_Take_Foo;

generic
function I_Take_Foo.Bar (...) return ...;

Being a child of I_Take_Foo, Bar receives Foo from its parent. I hope that
would suffice to perplex the prof... (:-))
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Jean-Pierre Rosen
2007-09-03 14:36:12 UTC
Permalink
Post by s***@gmail.com
generic
procedure Proc;
function Func (P1 : in Positive) return String;
Of course, the second line should be:
with procedure Proc;
--
---------------------------------------------------------
J-P. Rosen (***@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr
s***@gmail.com
2007-09-03 16:46:50 UTC
Permalink
Georg Bauhaus
2007-09-03 19:58:48 UTC
Permalink
Post by s***@gmail.com
generic
procedure Proc;
function Func (P1 : in Positive) return String;
Thanks pascal, but this is not what I meant. This is too easy for me
as well.
I think that Anon understood my question better. To create a generic
function that receives a procedure as a parameter..
Now it's just a general knowledge question ;-)
Aha! This explains a few misunderstandings, then. The word
"generic function"
has a formal meaning as an Ada term. This meaning is quite different
from "a function with a procedure parameter", which has formal
Ada meaning as well!

A generic function that receives a procedure will be something
like

type Procedure_Pointer is access procedure;

generic
...
function Some_Func(Proc: Procedure_Pointer) return Some_Type;

I guess you just want the third line.
Markus E L
2007-09-03 10:48:14 UTC
Permalink
Post by Pascal Obry
Post by s***@gmail.com
Do you have any ideas?
Yep, read your lesson :)
Sorry but this is really a trivial question, you must have seen this at
some point!
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
I'm trying to find the answer for 2 days. I've been studying the
language my self from the books, perhaps there is something that I'm
missing.
John Barnes: Programming in Ada 95; ISBN 201-87700-7; page 366 and following.

If that really took you 2 days (16 working hours?) and you didn't find
an answer to that, you probably should reconsider you choice of
profession. Sorry.
I've been answering questions from old exams, and this is the only
question I can't answer and it's driving me crazy.
So, perhaps you think you are very clever, but you don't know me, and
you don't know if I'm lazy or not.
But certainly you aren't competent either or your library is
absolutely bad.
So if you don't want to help, then
just don't and keep your smart remarks to your self.
Wow.

- M
anon
2007-09-03 10:23:22 UTC
Permalink
with Ada.text_IO ;
with System ;

procedure zzero is

function function_0 ( func : System.Address ; Data : Float )
return float is

procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;

begin -- function_0
tst ;
return Data * 2.0 ;
end function_0 ;


-- ---------- --
-- Test: Proc --
-- ---------- --

procedure test is
begin -- test
Ada.Text_IO.Put_Line ( "Testing" ) ;
end test ;


Result : Float ;

begin
Result := function_0 ( test'address, 0.5 ) ;
end zzero ;
Post by s***@gmail.com
I need your urgent help, I have an exam soon, and I still cant figure
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.
Do you have any ideas?
Thanks a lot.
R
Niklas Holsti
2007-09-03 10:42:21 UTC
Permalink
Post by anon
with Ada.text_IO ;
with System ;
procedure zzero is
function function_0 ( func : System.Address ; Data : Float )
return float is
procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;
I hope that the original poster understands that "anon's" answer is
not correct. I agree that the newsgroup should not supply
ready-made answers to homework or examination questions, but we
should not supply false answers either.

To the OP: surely your study materials contain examples of generic
functions or other generic components. Can you say more
specifically what you don't understand in those examples, or in the
question you are trying to solve?
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
s***@gmail.com
2007-09-03 10:58:36 UTC
Permalink
Post by Niklas Holsti
Post by anon
with Ada.text_IO ;
with System ;
procedure zzero is
function function_0 ( func : System.Address ; Data : Float )
return float is
procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;
I hope that the original poster understands that "anon's" answer is
not correct. I agree that the newsgroup should not supply
ready-made answers to homework or examination questions, but we
should not supply false answers either.
To the OP: surely your study materials contain examples of generic
functions or other generic components. Can you say more
specifically what you don't understand in those examples, or in the
question you are trying to solve?
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
Hi,
I realised that the answer proposed here, is working great, but it's
not really matching for what I was looking for. Perhaps I am looking
for something that I did not understand well.
While I was a student I got really sick, so now I got a special chance
to attend the exam (3 years later), therefor, I had to study the
language by my self.
I understood the generics, but I was looking to make a generic
function that receives an unknown procedure as a parameter, and runs
the procedure.
It's not like the 'regular' samples of " with function ">"(... "
I was wondering if there is a chance of creating a generic function
that receives an annonymous procedure.
After trying to explain the question to you, I think I misunderstood
the question, but still it bothers me.
In any case, if I will not pass this exam, I will start bothering you
here for the next few months :)
Thanks for your willing to help.
Ronit
Georg Bauhaus
2007-09-03 11:04:31 UTC
Permalink
Post by s***@gmail.com
I understood the generics, but I was looking to make a generic
function that receives an unknown procedure as a parameter, and runs
the procedure.
It's not like the 'regular' samples of " with function ">"(... "
I was wondering if there is a chance of creating a generic function
that receives an annonymous procedure.
Is anything known about the parameter profile of the procedure?
s***@gmail.com
2007-09-03 11:06:10 UTC
Permalink
Post by Georg Bauhaus
Post by s***@gmail.com
I understood the generics, but I was looking to make a generic
function that receives an unknown procedure as a parameter, and runs
the procedure.
It's not like the 'regular' samples of " with function ">"(... "
I was wondering if there is a chance of creating a generic function
that receives an annonymous procedure.
Is anything known about the parameter profile of the procedure?
simple empty procedure without any input parameters.
Georg Bauhaus
2007-09-03 12:00:28 UTC
Permalink
Post by s***@gmail.com
Post by Georg Bauhaus
Post by s***@gmail.com
I understood the generics, but I was looking to make a generic
function that receives an unknown procedure as a parameter, and runs
the procedure.
It's not like the 'regular' samples of " with function ">"(... "
I was wondering if there is a chance of creating a generic function
that receives an annonymous procedure.
Is anything known about the parameter profile of the procedure?
simple empty procedure without any input parameters.
Try thinking of a "non-empty" procedure and
how you would specify that as a generic formal procedure.

Then consider how, in general, you declare
(a) a procedure with parameters and
(b) a procedure without parameters.

Combine the two results.
anon
2007-09-03 11:24:24 UTC
Permalink
Dude.

He can learn generic on his own! That why my code did not include
any generic code. If you really look at the code you would have see
that.

Plus, If the guy looks that the numeric packages in GNAT he will
probability find exactly what he wants, in less than 5 minutes. GNAT
seams to have ever type of question answered in their source code.
Even if its bad programmimg. And in some places GNAT source code
even point out that its bad programming.

What I answered was, one way to access the procedure once
program called the function. And my code works in GNAT Ada. It
works for both a procedure with or without a parameter list.
Post by Niklas Holsti
Post by anon
with Ada.text_IO ;
with System ;
procedure zzero is
function function_0 ( func : System.Address ; Data : Float )
return float is
procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;
I hope that the original poster understands that "anon's" answer is
not correct. I agree that the newsgroup should not supply
ready-made answers to homework or examination questions, but we
should not supply false answers either.
To the OP: surely your study materials contain examples of generic
functions or other generic components. Can you say more
specifically what you don't understand in those examples, or in the
question you are trying to solve?
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
s***@gmail.com
2007-09-03 11:36:33 UTC
Permalink
Post by anon
Dude.
He can learn generic on his own! That why my code did not include
any generic code. If you really look at the code you would have see
that.
Plus, If the guy looks that the numeric packages in GNAT he will
probability find exactly what he wants, in less than 5 minutes. GNAT
seams to have ever type of question answered in their source code.
Even if its bad programmimg. And in some places GNAT source code
even point out that its bad programming.
What I answered was, one way to access the procedure once
program called the function. And my code works in GNAT Ada. It
works for both a procedure with or without a parameter list.
Post by Niklas Holsti
Post by anon
with Ada.text_IO ;
with System ;
procedure zzero is
function function_0 ( func : System.Address ; Data : Float )
return float is
procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;
I hope that the original poster understands that "anon's" answer is
not correct. I agree that the newsgroup should not supply
ready-made answers to homework or examination questions, but we
should not supply false answers either.
To the OP: surely your study materials contain examples of generic
functions or other generic components. Can you say more
specifically what you don't understand in those examples, or in the
question you are trying to solve?
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
- Show quoted text -
Hi, First, I'm a female.
Please don't post any more answers or such.
I understand according to what you wrote that I probably did not fully
understand the generics mechanism. In this case, even if you will
answer my question, it will not help me because my exam starts in an
hour.
I posted the question here, after trying to figure things out by my
self, and I had no intention to insult any one of you or to take
advantage of you.
In a way, I'm not worried of not passing the exam. The worse thing
that can happen is that I will take the course again, and gain my
knowledge from the teacher as well as from the books, because studying
ADA by your self is not simple.
Thanks a lot for your help.
I hope that some day I will be able to join this group as an equal
member and not just a student.
anon
2007-09-03 13:01:02 UTC
Permalink
Post by s***@gmail.com
Hi, First, I'm a female.
Sorry about calling you a guy, it is an easy mistake to make on the net.
Post by s***@gmail.com
Please don't post any more answers or such.
If you look here I will always answer a question with code if
possible! Its just the way I am. I even jump of people here for not
posting code. Because in a test my code or anyone else code is
not going to help, unless you understand it! And the only way is to
see the code.
Post by s***@gmail.com
I understand according to what you wrote that I probably did not fully
understand the generics mechanism. In this case, even if you will
answer my question, it will not help me because my exam starts in an
hour.
I posted the question here, after trying to figure things out by my
self, and I had no intention to insult any one of you or to take
advantage of you.
No insult or advantage of taken!
Post by s***@gmail.com
In a way, I'm not worried of not passing the exam. The worse thing
that can happen is that I will take the course again, and gain my
knowledge from the teacher as well as from the books, because studying
ADA by your self is not simple.
Actually, installing a free GNAT Ada version and starting to program
is the BEST way to learn. Teachers only have time to give you an
brief understand of any language. In the US that less than 45 hours
spanning 15 weeks. Outside programming is the only way to gain a
deeper understanding. And asking question with an expectation of an
answer is the second best way to gain a direction for that deeper
understand.

Plus, in my many years experience if a person just say read a section
or chapter than they also do not understand the problem or the
language. Even my professor would not do that, they would give an
example (like I did) and then assign someone an extra assignment that
would include the example as a small part of the whole project.

The only thing was their projects, either homework or extra
assignments were too simple for me, (bored me to death). I actually
had to expand them to make the worth my time. My Ada professor
use most of my work in Ada to teach his other classes at two
universities and wrote a number of text books using my classwork
that were used in both Europe and US universities.

What I did for my first Ada assignment after modifying it, was
rated at doctoral level programming. I even had to have permission
from 3 universities and their computer systems to fully execute the
assignment.
Post by s***@gmail.com
Thanks a lot for your help.
I hope that some day I will be able to join this group as an equal
member and not just a student.
I kind of believe that 50+ % of this group is students.
s***@gmail.com
2007-09-03 16:35:55 UTC
Permalink
Post by anon
Post by s***@gmail.com
Hi, First, I'm a female.
Sorry about calling you a guy, it is an easy mistake to make on the net.
Post by s***@gmail.com
Please don't post any more answers or such.
If you look here I will always answer a question with code if
possible! Its just the way I am. I even jump of people here for not
posting code. Because in a test my code or anyone else code is
not going to help, unless you understand it! And the only way is to
see the code.
Post by s***@gmail.com
I understand according to what you wrote that I probably did not fully
understand the generics mechanism. In this case, even if you will
answer my question, it will not help me because my exam starts in an
hour.
I posted the question here, after trying to figure things out by my
self, and I had no intention to insult any one of you or to take
advantage of you.
No insult or advantage of taken!
Post by s***@gmail.com
In a way, I'm not worried of not passing the exam. The worse thing
that can happen is that I will take the course again, and gain my
knowledge from the teacher as well as from the books, because studying
ADA by your self is not simple.
Actually, installing a free GNAT Ada version and starting to program
is the BEST way to learn. Teachers only have time to give you an
brief understand of any language. In the US that less than 45 hours
spanning 15 weeks. Outside programming is the only way to gain a
deeper understanding. And asking question with an expectation of an
answer is the second best way to gain a direction for that deeper
understand.
Plus, in my many years experience if a person just say read a section
or chapter than they also do not understand the problem or the
language. Even my professor would not do that, they would give an
example (like I did) and then assign someone an extra assignment that
would include the example as a small part of the whole project.
The only thing was their projects, either homework or extra
assignments were too simple for me, (bored me to death). I actually
had to expand them to make the worth my time. My Ada professor
use most of my work in Ada to teach his other classes at two
universities and wrote a number of text books using my classwork
that were used in both Europe and US universities.
What I did for my first Ada assignment after modifying it, was
rated at doctoral level programming. I even had to have permission
from 3 universities and their computer systems to fully execute the
assignment.
Post by s***@gmail.com
Thanks a lot for your help.
I hope that some day I will be able to join this group as an equal
member and not just a student.
I kind of believe that 50+ % of this group is students.
Hi, Thanks for your kind response.
I just came back from the exam. It was not very difficult but I can't
say it was easy. I don't believe I passed, but it's ok. I don't mind
attending the course again, Ada is a nice and very powerful language,
and I wouldn't mind getting to know it better.
I'm going to get some rest now. Thanks :)
anon
2007-09-04 00:38:10 UTC
Permalink
-- A more complete answer since your through with your test. And yes
-- you can copy and paste this code into a a file and use the gnat
-- system to compile/bind/link and then excute the program.
--
-- In most cases there are a number of ways to create code. Some are
-- more direct or aids the compiler to help you while others are more
-- indirect or toward the system performance and code usage. I did have
-- seven ways of answering the question but the other 3 were too
-- complex for a beginner. Even one use the generic package
-- caled "System.Address_To_Access_Conversions"
--
-- But in true Generic the function should be able to handle all
-- types of calls both Ada and non-Ada procedure.
--
-- In GNAT both Access and Address are the same but with other
-- system where memory is protected or even using seperate
-- memories this may not be the case.
--

with Ada.text_IO ;
with System ;

--
-- see function_3, might be too complex.
--
with Ada.Unchecked_Conversion ;

procedure zzero is

--
-- This allows all types of procedures both Ada and external
-- with or without parameters. Creates a static procedure
-- design effect.
--
function function_0 ( func : System.Address ; Data : Float )
return float is

procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;

begin -- function_0
tst ;
return Data * 2.0 ;
end function_0 ;

------------------------------------------------------------------------------
-- The Probability the answer that she ask for: --
-- --
-- type proc_access is access procedure ; -- is the generic statement --
-- -- that she needed. --
-- --
-- tst.all ; -- statement to call set --
-- -- procedure --
-- --
------------------------------------------------------------------------------
--
-- This version allows only procedures that are Ada without
-- parameters.
--

type proc_access is access procedure ;

function function_1 ( tst : proc_access ; Data : Float )
return float is

begin -- function_1
tst.all ;
return Data * 2.0 ;
end function_1 ;



--
-- This version allows only procedures that are Ada without
-- parameters. Creates a static procedure design effect for
-- calling procedure.
--

type func_access is access procedure ;

function function_2 ( func : func_access ; Data : Float )
return float is

procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func.all'address ;

begin -- function_2
tst ;
return Data * 2.0 ;
end function_2 ;


--
-- This version allows only procedures that are Ada without
-- parameters. And also use another Generic package to
-- convert the addressing schemes that creates a static
-- procedure design effect. But shows that both can be used
-- in the same package.
--
type procedure_access is access procedure ;

function function_3 ( func : procedure_access ; Data : Float )
return float is


-- --------------------------------------- --
-- use for calling method version two only --
-- --------------------------------------- --

--
-- limit this conversion function to function_3 usage only
--
function PA_To_A is new Ada.Unchecked_Conversion
( Source => procedure_access,
Target => System.Address ) ;

procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use PA_To_A ( func ) ;

begin -- function_3
--
-- simple dynamic call version method 1
--
func.all ;
--
-- simple static call version method 2
--
tst ;
return Data * 2.0 ;
end function_3 ;


-- ---------- --
-- Test: Proc --
-- ---------- --

procedure test is
begin -- test
Ada.Text_IO.Put_Line ( "Testing" ) ;
end test ;


Result : Float ;

begin
Result := function_0 ( test'address, 0.5 ) ;
--
Result := function_1 ( test'access, 0.7 ) ;
Result := function_2 ( test'access, 0.9 ) ;
--
Result := function_3 ( test'access, 0.1 ) ;

end zzero ;
Post by s***@gmail.com
Post by anon
Post by s***@gmail.com
Hi, First, I'm a female.
Sorry about calling you a guy, it is an easy mistake to make on the net.
Post by s***@gmail.com
Please don't post any more answers or such.
If you look here I will always answer a question with code if
possible! Its just the way I am. I even jump of people here for not
posting code. Because in a test my code or anyone else code is
not going to help, unless you understand it! And the only way is to
see the code.
Post by s***@gmail.com
I understand according to what you wrote that I probably did not fully
understand the generics mechanism. In this case, even if you will
answer my question, it will not help me because my exam starts in an
hour.
I posted the question here, after trying to figure things out by my
self, and I had no intention to insult any one of you or to take
advantage of you.
No insult or advantage of taken!
Post by s***@gmail.com
In a way, I'm not worried of not passing the exam. The worse thing
that can happen is that I will take the course again, and gain my
knowledge from the teacher as well as from the books, because studying
ADA by your self is not simple.
Actually, installing a free GNAT Ada version and starting to program
is the BEST way to learn. Teachers only have time to give you an
brief understand of any language. In the US that less than 45 hours
spanning 15 weeks. Outside programming is the only way to gain a
deeper understanding. And asking question with an expectation of an
answer is the second best way to gain a direction for that deeper
understand.
Plus, in my many years experience if a person just say read a section
or chapter than they also do not understand the problem or the
language. Even my professor would not do that, they would give an
example (like I did) and then assign someone an extra assignment that
would include the example as a small part of the whole project.
The only thing was their projects, either homework or extra
assignments were too simple for me, (bored me to death). I actually
had to expand them to make the worth my time. My Ada professor
use most of my work in Ada to teach his other classes at two
universities and wrote a number of text books using my classwork
that were used in both Europe and US universities.
What I did for my first Ada assignment after modifying it, was
rated at doctoral level programming. I even had to have permission
from 3 universities and their computer systems to fully execute the
assignment.
Post by s***@gmail.com
Thanks a lot for your help.
I hope that some day I will be able to join this group as an equal
member and not just a student.
I kind of believe that 50+ % of this group is students.
Hi, Thanks for your kind response.
I just came back from the exam. It was not very difficult but I can't
say it was easy. I don't believe I passed, but it's ok. I don't mind
attending the course again, Ada is a nice and very powerful language,
and I wouldn't mind getting to know it better.
I'm going to get some rest now. Thanks :)
Georg Bauhaus
2007-09-04 06:38:25 UTC
Permalink
Post by anon
------------------------------------------------------------------------------
-- The Probability the answer that she ask for: --
-- --
-- type proc_access is access procedure ; -- is the generic statement --
-- -- that she needed. --
I'm not sure I understand "generic statement" here.
Proc_Access looks like an access to subprogram type.
What is a generic statement?
anon
2007-09-05 03:47:24 UTC
Permalink
The English language has many different definitions of the word 'generic',
none of them deal with Ada. Which can cause confusion when trying to
answer someone question, if you do not know the semantics of the word
'generic' or the phase 'generic statement'.

The Lady was not speaking of the "GENERIC" keyword in Ada. Also
another clue was this was her first test. Basically, testing her
knowledge of Reserved words, program structures, basic data types
(defined in the "Standard package"), etc. And how to call a
procedure and function, which as the base of her question.

Testing for user-defined packages and possible the "Generic" type
packages may be in second test.
Post by Georg Bauhaus
Post by anon
------------------------------------------------------------------------------
-- The Probability the answer that she ask for: --
-- --
-- type proc_access is access procedure ; -- is the generic statement --
-- -- that she needed. --
I'm not sure I understand "generic statement" here.
Proc_Access looks like an access to subprogram type.
What is a generic statement?
Georg Bauhaus
2007-09-05 10:11:19 UTC
Permalink
Post by anon
The English language has many different definitions of the word 'generic',
none of them deal with Ada. Which can cause confusion when trying to
answer someone question, if you do not know the semantics of the word
'generic' or the phase 'generic statement'.
Yes, obviously. But is it the best way to remove misunderstandings
by again employing a misleading meaning of "generic" as in
"generic statement" for "access to procedure" a.k.a. procedure
pointer? (I'm saying this because communicating anything becomes
O(terrible(n)), time consuming, entails anger and cost because
misunderstandings can lead to work in the wrong direction etc.
Words are then overloaded in a piece of information that should
be specific, i.e., not overloaded. I'm not denying the
usefulness of understanding what the intended meaning was,
only that it should not be adopted.)
Post by anon
Post by Georg Bauhaus
Post by anon
------------------------------------------------------------------------------
-- The Probability the answer that she ask for: --
-- --
-- type proc_access is access procedure ; -- is the generic statement --
-- -- that she needed. --
I'm not sure I understand "generic statement" here.
Proc_Access looks like an access to subprogram type.
What is a generic statement?
anon
2007-09-05 12:36:01 UTC
Permalink
When you answer a post you direct your answers and your comments to
the original poster or the previous poster only. And since the original
poster in this case, used the word 'Generic' that means that if I change
the word it might confuse her. Just because others may listen in does
not change the fact that I was talking to the original or previous poster.
You use the language and semantics that the original or previous poster
should know. That way they understand which is the reason the answer
was given. Others may listen in may or may not like the answer given
or even understand the answer, but that's their problem. Because the
answer was not given for them, its for the original or previous poster.

Also that English for you! We use the same word to mean many things
instead of creating a new words. Plus, like all of us we use the
semantics and slang that we know and sometime it can be confusing
to others, but to keep the peace we must all learn to get over that.

And only reading the last sets of posts of a thread one is more
likely to misunderstand any and all parts of the thread. To help
keep from misunderstanding someone, you first need to find the
original poster and read what they stated.

I knew what she meant and wanted from her statement, but in
reading other post I was not sure they did.

I think most posters just Keyed on the word 'Generic' and did
not understand her complete question, so they tried to send her to
the LRM chapter 12, that deals with "Generic Units". And the
misunderstanding is not the original poster fault. You will see
this if you follow the complete thread. She even lets people know
that it had nothing to do with Ada's "Generic Units".


Language misunderstanding can and will happen from time to time we just
have to deal with it. That's the way the world works and its not going to
change anytime soon.
Post by Georg Bauhaus
Post by anon
The English language has many different definitions of the word 'generic',
none of them deal with Ada. Which can cause confusion when trying to
answer someone question, if you do not know the semantics of the word
'generic' or the phase 'generic statement'.
Yes, obviously. But is it the best way to remove misunderstandings
by again employing a misleading meaning of "generic" as in
"generic statement" for "access to procedure" a.k.a. procedure
pointer? (I'm saying this because communicating anything becomes
O(terrible(n)), time consuming, entails anger and cost because
misunderstandings can lead to work in the wrong direction etc.
Words are then overloaded in a piece of information that should
be specific, i.e., not overloaded. I'm not denying the
usefulness of understanding what the intended meaning was,
only that it should not be adopted.)
Post by anon
Post by Georg Bauhaus
Post by anon
------------------------------------------------------------------------------
-- The Probability the answer that she ask for: --
-- --
-- type proc_access is access procedure ; -- is the generic statement --
-- -- that she needed. --
I'm not sure I understand "generic statement" here.
Proc_Access looks like an access to subprogram type.
What is a generic statement?
Georg Bauhaus
2007-09-05 13:50:13 UTC
Permalink
Post by anon
since the original
poster in this case, used the word 'Generic' that means that if I change
the word it might confuse her.
Right, this is why I suggested that the confusion might
best be removed by mentioning the misunderstanding
in your program or near it. Like, "you called it generic,
maybe because ..., but in Ada, generic means something
different. So it is better to not call it generic and
instead use ..."
(You would have used that other, correct, word in your
comment next to the access to subprogram type.)

This would have cleared up the situation for her and
for everyone else:

(a) She would have known that generic means something
different in Ada. Now she would have to figure that out
herself (if necessary), in part because your comment
confirms her misleading use of the word. This might
leave one task open that could easily have been closed.

(b) Everyone else would have said, Ah, I see. And
presented more helpful pointers.
Post by anon
Plus, like all of us we use the
semantics and slang that we know and sometime it can be confusing
to others, but to keep the peace we must all learn to get over that.
It is a plus if you learn how to denote things not just using
slang but also using words that are slightly more formally correct.
That's one way of reducing confusion.
anon
2007-09-05 14:40:48 UTC
Permalink
I guess I will put you into the TROLL package with Markus E L

You should NEVER tell someone in a Forum or Newsgroup that is visted by
the world, how to ask a question. They will ask how they understand the
the idea and in the way they can. Plus, you can always skip the post!

And if you get confursed THAT IS YOUR PROBLEM not anyone elses! You
may need to learn how others ask questions.

Even if the world spoke a Single World Language there will still be
confusion, JUST DEAL WITH IT!

If you do not own the Forum or Newsgroup then the best policy is keep your
DICTATOR TRASH ideas to yourself! DUDE!
Post by Georg Bauhaus
Post by anon
since the original
poster in this case, used the word 'Generic' that means that if I change
the word it might confuse her.
Right, this is why I suggested that the confusion might
best be removed by mentioning the misunderstanding
in your program or near it. Like, "you called it generic,
maybe because ..., but in Ada, generic means something
different. So it is better to not call it generic and
instead use ..."
(You would have used that other, correct, word in your
comment next to the access to subprogram type.)
This would have cleared up the situation for her and
(a) She would have known that generic means something
different in Ada. Now she would have to figure that out
herself (if necessary), in part because your comment
confirms her misleading use of the word. This might
leave one task open that could easily have been closed.
(b) Everyone else would have said, Ah, I see. And
presented more helpful pointers.
Post by anon
Plus, like all of us we use the
semantics and slang that we know and sometime it can be confusing
to others, but to keep the peace we must all learn to get over that.
It is a plus if you learn how to denote things not just using
slang but also using words that are slightly more formally correct.
That's one way of reducing confusion.
Georg Bauhaus
2007-09-05 18:10:47 UTC
Permalink
Post by anon
I guess I will put you into the TROLL package with Markus E L
You should NEVER tell someone in a Forum or Newsgroup that is visted by
the world, how to ask a question. They will ask how they understand the
the idea and in the way they can. Plus, you can always skip the post!
(I suspect a few cultural misunderstandings in this--please consider
I'm German and as such insufficiently restrained in NG discussions--
there is no excuse.)

I should have expressed myself more clearly. I'm not asking
anyone to ask questions so that I can understand them. Good heavens!
I did suggest, even though you didn't ask me to do so, that *answering*
the question can include an option to just provide that additional bit
of information to the OP that will help avoid future misunderstandings
on either side. There is of course absolutely nothing wrong with
asking a question using whatever words one has available!
However, I do think that *without* additional explanation, it is
really doing a disservice when an answer calls an access type
declaration a "generic statement" even when this is only done
to refer indirectly to the OP's question. I shouldn't have told
you what to do, though. Sorry if that comment hurts you.
Post by anon
Even if the world spoke a Single World Language there will still be
confusion, JUST DEAL WITH IT!
Yes, certainly. However, IMHO, dealing with confusion in a NG does not
always entail the silence and confirmative attitude you have to
adopt when a superior asks you a question using technically
unusual words. Again, nothing wrong with the question!
And it is my task trying to understand the question. In a NG,
there is a chance to provide information about words used in the
question in addition to confirming the question, even when it contains
a few bits that sound like a correction.
I'll try to be more considerate in the future.
Ed Falis
2007-09-06 00:04:50 UTC
Permalink
Post by anon
I guess I will put you into the TROLL package with Markus E L
You've got an awful lot of negative stuff to say for someone without the
cajuns to use his own name. Expect that it's taken with a relevant level
of esteem. I happen to find Herr Bauhaus one of the most reasonable (and
factual) posters on this newsgroup.
anon
2007-09-06 02:54:42 UTC
Permalink
The problem is Georg Bauhaus forgot that this newgroup is about the
computer language known as 'Ada'. It can include aspects of Ada such
as the history and future. And other computer languages along with the
computer system and projects that are used by with Ada.

But there is no room on the this newgroup and most would say the entire
net for someone to cut down how someone uses the English language or
any other language in asking or answering a question.

That decision belongs to another group that only deals with that spoke
and written language. And if you do not understand what someone says
skip it and move to the next post. Instead of getting mad and wasting
time writing down a response that does not belong move to the next
post.


Enough about this! Lets get back to Ada the computer language!

Now, as for my name! Who cares! I am a humun being and a part of
this world's human population and that's all you need to know.
Post by Ed Falis
Post by anon
I guess I will put you into the TROLL package with Markus E L
You've got an awful lot of negative stuff to say for someone without the
cajuns to use his own name. Expect that it's taken with a relevant level
of esteem. I happen to find Herr Bauhaus one of the most reasonable (and
factual) posters on this newsgroup.
Markus E L
2007-09-06 09:20:38 UTC
Permalink
Post by anon
The problem is Georg Bauhaus forgot that this newgroup is about the
computer language known as 'Ada'. It can include aspects of Ada such
as the history and future. And other computer languages along with the
computer system and projects that are used by with Ada.
But there is no room on the this newgroup and most would say the entire
net for someone to cut down how someone uses the English language or
any other language in asking or answering a question.
That decision belongs to another group that only deals with that spoke
and written language. And if you do not understand what someone says
skip it and move to the next post. Instead of getting mad and wasting
time writing down a response that does not belong move to the next
post.
Thanks for policing the group. That's exactly what we all needed: An
anonymous police man. BTW in Germany we have a nice name for someone
like that: Blockwart.

-- Markus
Post by anon
Enough about this! Lets get back to Ada the computer language!
Now, as for my name! Who cares! I am a humun being and a part of
this world's human population and that's all you need to know.
Post by Ed Falis
Post by anon
I guess I will put you into the TROLL package with Markus E L
You've got an awful lot of negative stuff to say for someone without the
cajuns to use his own name. Expect that it's taken with a relevant level
of esteem. I happen to find Herr Bauhaus one of the most reasonable (and
factual) posters on this newsgroup.
Dirk Heinrichs
2007-09-06 06:15:39 UTC
Permalink
Post by Ed Falis
Post by anon
I guess I will put you into the TROLL package with Markus E L
You've got an awful lot of negative stuff to say for someone without the
cajuns to use his own name.
It's not the first time, see:

http://groups.google.com/group/comp.lang.ada/browse_thread/thread/71b4c0131a8a22a4/4796ffdd00646978

Bye...

Dirk
--
Dirk Heinrichs | Tel: +49 (0)162 234 3408
Configuration Manager | Fax: +49 (0)211 47068 111
Capgemini Deutschland | Mail: ***@capgemini.com
Wanheimerstraße 68 | Web: http://www.capgemini.com
D-40468 Düsseldorf | ICQ#: 110037733
GPG Public Key C2E467BB | Keyserver: www.keyserver.net
Markus E L
2007-09-06 09:18:45 UTC
Permalink
Post by Ed Falis
Post by anon
I guess I will put you into the TROLL package with Markus E L
You've got an awful lot of negative stuff to say for someone without
the cajuns to use his own name. Expect that it's taken with a
relevant level of esteem. I happen to find Herr Bauhaus one of the
most reasonable (and factual) posters on this newsgroup.
I (being a troll :-) find his reasoning sometimes fuzzy, but he
certainly doesn't take offense easily for which I'd like to thank
him. I never would have answered anon's diatribe with "I'll try to be
more considerate". But perhaps there is just a grain of irony in
there?

Regards -- Markus
Markus E L
2007-09-05 11:37:21 UTC
Permalink
Post by anon
The English language has many different definitions of the word 'generic',
none of them deal with Ada. Which can cause confusion when trying to
answer someone question, if you do not know the semantics of the word
'generic' or the phase 'generic statement'.
The Lady was not speaking of the "GENERIC" keyword in Ada. Also
another clue was this was her first test. Basically, testing her
knowledge of Reserved words, program structures, basic data types
(defined in the "Standard package"), etc. And how to call a
procedure and function, which as the base of her question.
Testing for user-defined packages and possible the "Generic" type
packages may be in second test.
So you know the "the ladies" college and how they take tests? (Or are
you trying to pose as an educational expert here)?

- M
Ludovic Brenta
2007-09-03 13:27:36 UTC
Permalink
Post by s***@gmail.com
In a way, I'm not worried of not passing the exam. The worse thing
that can happen is that I will take the course again, and gain my
knowledge from the teacher as well as from the books, because studying
ADA by your self is not simple.
Thanks a lot for your help.
I hope that some day I will be able to join this group as an equal
member and not just a student.
Truly you have mastered the Tao of Programming. I have no doubt you
will succeed now or later. I hope you learn so much you can later
teach us!

--
Ludovic Brenta.
Markus E L
2007-09-03 13:18:12 UTC
Permalink
Post by anon
Dude.
He can learn generic on his own! That why my code did not include
any generic code. If you really look at the code you would have see
that.
Yeah. "He can answer his question by himself, so I don't include the
answer. But wait: Just let's give him another slightly bizarre answer,
so that he has gotten some answer".

Though I have to admit that you never said that your _response_ was an
_answer_ to his question. Funny.

Regards -- Markus
t***@acm.org
2007-09-03 16:18:52 UTC
Permalink
Post by anon
procedure test is
begin -- test
Ada.Text_IO.Put_Line ( "Testing" ) ;
end test ;
Result : Float ;
begin
Result := function_0 ( test'address, 0.5 ) ;
end zzero ;
Ada is designed so the compiler can help catch errors, but if you
would rather hide the nature of the parameter to function_0 from the
compiler, and use a debugger to find the resulting errors yourself, try:
procedure test1(x : in Integer) is
begin
Ada.Text_IO.Put_Line ( "Test1" & Integer'image(x));
end test1;

test2 : float;

and
Result := function_0 ( test1'address, 0.5 ) ;
Result := function_0 ( test2'address, 0.5 ) ;
anon
2007-09-03 21:39:40 UTC
Permalink
Your code does not solve any form of the lady's question! Which stated that
the procedure did not have a parameter!

I answer how to call a procedure from a function, where the procedure was
passed in the functional pararmeter list.
Post by t***@acm.org
Post by anon
procedure test is
begin -- test
Ada.Text_IO.Put_Line ( "Testing" ) ;
end test ;
Result : Float ;
begin
Result := function_0 ( test'address, 0.5 ) ;
end zzero ;
Ada is designed so the compiler can help catch errors, but if you
would rather hide the nature of the parameter to function_0 from the
procedure test1(x : in Integer) is
begin
Ada.Text_IO.Put_Line ( "Test1" & Integer'image(x));
end test1;
test2 : float;
and
Result := function_0 ( test1'address, 0.5 ) ;
Result := function_0 ( test2'address, 0.5 ) ;
Markus E L
2007-09-03 10:56:55 UTC
Permalink
Post by anon
with Ada.text_IO ;
with System ;
procedure zzero is
function function_0 ( func : System.Address ; Data : Float )
return float is
procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;
begin -- function_0
tst ;
return Data * 2.0 ;
end function_0 ;
-- ---------- --
-- Test: Proc --
-- ---------- --
procedure test is
begin -- test
Ada.Text_IO.Put_Line ( "Testing" ) ;
end test ;
Result : Float ;
begin
Result := function_0 ( test'address, 0.5 ) ;
end zzero ;
Wow, thanks. That clearly illustrates what I've been secretly
suspecting for some time: That '***@anon.org', the great and only
with suuuuuch a long history in Ada and whatever, has no, absolutely
no clue about Ada. I notice with joy that the keyword 'generic' is
completely absent from your "solution" and the thing called 'func' is
a System.Address. Looks like something a (bad) C programmer might have
conceived after missing to read the introductory Ada material (e.g. a
decent book or the ARM, which is astonishingly readable).

Regards -- Markus
Post by anon
Post by s***@gmail.com
I need your urgent help, I have an exam soon, and I still cant figure
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.
Do you have any ideas?
Thanks a lot.
R
anon
2007-09-05 03:49:35 UTC
Permalink
Move On son! Move On! No one cares what you say any more!
Post by Markus E L
Post by anon
with Ada.text_IO ;
with System ;
procedure zzero is
function function_0 ( func : System.Address ; Data : Float )
return float is
procedure tst ;
pragma Import ( Ada, tst ) ;
for tst'address use func ;
begin -- function_0
tst ;
return Data * 2.0 ;
end function_0 ;
-- ---------- --
-- Test: Proc --
-- ---------- --
procedure test is
begin -- test
Ada.Text_IO.Put_Line ( "Testing" ) ;
end test ;
Result : Float ;
begin
Result := function_0 ( test'address, 0.5 ) ;
end zzero ;
Wow, thanks. That clearly illustrates what I've been secretly
with suuuuuch a long history in Ada and whatever, has no, absolutely
no clue about Ada. I notice with joy that the keyword 'generic' is
completely absent from your "solution" and the thing called 'func' is
a System.Address. Looks like something a (bad) C programmer might have
conceived after missing to read the introductory Ada material (e.g. a
decent book or the ARM, which is astonishingly readable).
Regards -- Markus
Post by anon
Post by s***@gmail.com
I need your urgent help, I have an exam soon, and I still cant figure
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.
Do you have any ideas?
Thanks a lot.
R
Markus E L
2007-09-05 11:35:23 UTC
Permalink
Post by anon
Move On son! Move On! No one cares what you say any more!
Yes, really, anonymous Dad?

I remember your contributions regarding the meaning of the GPL and Ada
history. I think, some people cared for that, but I suspect rather
because of the entertainment value -- you remember the conspirational
theoretic part how the DOD is controlling all online sources and the
Walnut Creek CD is the (only?) authoritative one?

Give the drivel you have been posting elsewhere I understand rather
well that you don't post under your real name.

- M
g***@hotmail.com
2007-09-03 11:39:45 UTC
Permalink
Post by s***@gmail.com
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.
Do you have any ideas?
Use a something called a search engine, e.g.
http://www.google.com/search?q=generic+procedure+ada
and / or look in the Reference Manual...
Challenge: you have 5 clicks to find an example!
______________________________________________________________
Gautier -- http://www.mysunrise.ch/users/gdm/index.htm
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!
s***@gmail.com
2007-09-03 11:59:48 UTC
Permalink
Post by g***@hotmail.com
Post by s***@gmail.com
I want to create a generic function that receives a generic procedure
(without any parameters) as a parameter.
Do you have any ideas?
Use a something called a search engine, e.g.
http://www.google.com/search?q=generic+procedure+ada
and / or look in the Reference Manual...
Challenge: you have 5 clicks to find an example!
______________________________________________________________
Gautier --http://www.mysunrise.ch/users/gdm/index.htm
Ada programming --http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
I tried to do the challenge, but really I didn't find the answer in
the short time I had. I have to go to the exam now.
If you don't mind, answering me just to help me understand, I will
look at it after the exam, and maybe then I will understand. Now it's
too late for me.
BTW, I studied according to 2 books. 1 of them is not in English, it's
of my university, and the other one is: Object-oriented software in
ada95 2nd edition by Michael A. Smith.
I read them both and did excersizes. Perhaps its because the stress, I
can't figure it out now.
I hope you wish me luck.
I'll login in a few hours to see what I was missing..
Thanks
Continue reading on narkive:
Loading...