comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Problem With Self-Referential Access-to-Subprogram Type
Date: Thu, 06 Nov 2003 12:45:42 -0500
Date: 2003-11-06T12:45:42-05:00	[thread overview]
Message-ID: <GMvqb.21235$mB5.930660@news20.bellglobal.com> (raw)
In-Reply-To: <c8f570aa.0311051454.4e3928d0@posting.google.com>

Tad Ashlock wrote:

> Marius Amado Alves <amado.alves@netcabo.pt> wrote in message news:<mailman.285.1068058551.25614.comp.lang.ada@ada-france.org>...
> 
>>On Wed, 2003-11-05 at 17:49, Adam Beneschan wrote:
>>
>>>... The feeling at the time was that
>>>the additional work needed to change the language and the compilers
>>>shouldn't be required if no one has run into the problem in practice. 
>>>I've let them know that someone now has run into it.
>>
>>Did you verify that the problem was "real"? The example does not seem to
>>show enough. Can be just an experimentation of the general construction,
>>with no specific application in mind. Some newbies do that. (In which
>>case the 2002 decision should probably stand. Private types solve the
>>general problem.)
> 
> Well, as the OP I can't really say how "real" the problem is.  But I
> can describe what it is I'm trying to accomplish.
> 
> What I'm trying to do is implement (in Ada) the ideas in the book
> "Practical Statecharts in C/C++" by Miro Samek, CMP Books, 2002, ISBN
> 1-57820-110-1 <http://www.quantum-leaps.com/writings/book.htm>.  The
> (quite ingenious) idea is that the current state of a hierarchical
> state machine can be represented by nothing more than a reference (a
> function pointer in C++) to the state handling function.  And to
> implement the hierarchical aspect of statecharts, each state handling
> function returns a reference to its parent state if it doesn't handle
> the passed-in event itself.
> 
> Of course there are other ways of getting the required information
> back from the state handler, but I am trying to keep the Ada
> implementation similar to the original C++ implementation.  At least

I know this doesn't map to the "C++ way", but would not an
array of function pointers with an enumerated type to choose
the function not work?  Rather than working with "pointers",
directly, you choose the pointer using the enumerated type
as an array subscript. This also avoids violating the
"never compare pointers" rule (not all platforms guarantee
that the representation of 2 equivalent addresses will be
identical). This may come up when you need to compare if
one state is equal to another. Comparing pointers may work
on most modern platforms, it is not guaranteed to work
(I think segmented architectures is where you have the
greatest difficulty with this).
-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




  reply	other threads:[~2003-11-06 17:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-03 16:58 Problem With Self-Referential Access-to-Subprogram Type Tad Ashlock
2003-11-04 10:04 ` Dmitry A. Kazakov
2003-11-04 13:52   ` Tad Ashlock
2003-11-04 14:24     ` Dmitry A. Kazakov
2003-11-04 14:52       ` Marius Amado Alves
2003-11-05  8:31         ` Dmitry A. Kazakov
2003-11-05 11:27           ` Marius Amado Alves
2003-11-05 13:33             ` Dmitry A. Kazakov
2003-11-05 14:02               ` Marius Amado Alves
2003-11-05 17:49             ` Adam Beneschan
2003-11-05 18:55               ` Marius Amado Alves
2003-11-05 22:54                 ` Tad Ashlock
2003-11-06 17:45                   ` Warren W. Gay VE3WWG [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-11-03 17:32 amado.alves
2003-11-04 14:02 ` Tad Ashlock
replies disabled

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