comp.lang.ada
 help / color / mirror / Atom feed
From: Mats Karlssohn <mats@mida.se>
Subject: Re: newbie can't get exceptions to work!
Date: Wed, 11 Apr 2001 13:49:22 +0200
Date: 2001-04-11T11:50:32+00:00	[thread overview]
Message-ID: <3AD444C2.A0E41152@mida.se> (raw)
In-Reply-To: LCEA6.1941$FY5.138439@www.newsranger.com

Ted Dennison wrote:
> 
> In article <3AD2AF50.6B5DD470@mida.se>, Mats Karlssohn says...
> >
> >Could we get the language to handle dispatching calls that in some of
> >the
> >cases dispatches to a function and in some cases just get the return
> >value
> >from one array *big smile* ? I've quite recently implemented a hirarchy
> >with these properties by wrapping the arrays in functions. It would be
> >nice if the compiler could generate the wrappers by itself. But maybe
> 
> Interesting example. :-)

Thanks, I try to be an interesting guy ;)

> First off, I don't think it would be consistent to do this kind of thing unless
> you also allowed an array to be a tagged type (not a component, but a tagged
> type in and of itself). Otherwise, what's the syntax for deciding what array to
> use? There may be some neat way of doing that, but I don't see it.

In my example the arrays were components of a tagged record, but
generalizing them to be tagged types themselves would be at least
interesting, possibly fruitful.

To clarify: I made an hirarchy (spl ?) of tagged records, one
dispatched function takes an integer argument and returns a
string. For some cases, the string needs to be calculated from
other components in the record. For other cases the string is
constant only depending on the integer, and thus (IMHO) best
implemented as an array of (constant) strings, so I had to
implement (inlined) functions that returns a value from the
array. Implementing the functions were no major hassle, since
there were quite few of them, BUT it feels kind of stupid to
do it this way.

As I'm writing this I realize that I should have tried to
implement the lookup functions as a generic function. I'll
have to try that (shouldn't be a big problem I guess).

BTW, the system I'm talking about in the example is part of
a status monitoring for distributed embedded processors. The
part I'm discussing is translating numeric status codes to
human readable messages.

> But let's pretend that wasn't an issue (now we're off in never-never land of
> course). In other posts I've been equating array indexing to an automaticly
> pragma-inlined canned mapping function.

Yes, IMHO that's a correct way of viewing it. I do have some
background in formal logic so I can se most relations as mapping
functions. However, I can also see the view that an array is just
data storage (thus ignoring the work needed to access the data).

> Now I think dispatching can be split into two cases: dynamic and static. Static
> dispatch is just the insertion of the proper type's function call into the
> generated code. It shouldn't be too big of a deal for a compile to insert the
> indexing code rather than a function call when appropriate.

Yes.

> For dynamic dispatch, the compiler essentially generates a big case statement,
> based on the object's tag, where each branch contains a function call. You could
> also think of it as a jump (to subroutine) table. Now if the compiler is just
> doing a table lookup and JSR'ing to the result, then there's going to be a
> subroutine call anyway. So you aren't really buying anything by not having to
> write that function that does nothing but index into an array.

That's right I guess. What is saved is the work of writing the
lookup functions (not a big deal) and more important we save
som cluttering of the source. I'd say that it'd be easier to
read if the compiler automatically generated the lookup function.

> However, if it actually is a big case statement, then there would be nothing
> wrong with having an inlined routine on one of the branches. In that case it
> would be doable. (Is pragma inline allowed for a dispatching call?)

Exactly my point. I don't know if it's legal or not.

-- 
Mats Karlssohn, developer                         mailto:mats@mida.se  
Mida Systemutveckling AB                          http://www.mida.se
Box 64, S-732 22 ARBOGA, SWEDEN
Phone: +46-(0)589-89808   Fax: +46-(0)589-89809



  parent reply	other threads:[~2001-04-11 11:49 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-05  3:19 newbie can't get exceptions to work! Jeff Shipman
2001-04-05  4:25 ` Ed Falis
2001-04-05 11:00   ` martin.m.dowie
2001-04-05 14:21     ` Ted Dennison
2001-04-05 17:50       ` Fraser Wilson
2001-04-05  4:34 ` Jeff Shipman
2001-04-05  4:59 ` Wilhelm Spickermann
2001-04-05 14:14   ` Ted Dennison
2001-04-05 16:37     ` Wilhelm Spickermann
2001-04-06 13:09     ` Marc A. Criley
2001-04-06 15:04       ` Ted Dennison
2001-04-06 16:43       ` Robert A Duff
2001-04-06 17:39         ` Ted Dennison
2001-04-06 21:50           ` Robert A Duff
2001-04-06 20:11         ` Brian Rogoff
2001-04-06 22:20           ` Robert A Duff
2001-04-06 23:04             ` Brian Rogoff
2001-04-07  5:48               ` Jeffrey Carter
2001-04-10  1:29                 ` Robert A Duff
2001-04-07 19:30               ` Robert A Duff
2001-04-07 21:17                 ` Brian Rogoff
2001-04-07 21:25                   ` Ayende Rahien
2001-04-07 22:57                     ` David Starner
2001-04-08 12:10                       ` Ayende Rahien
2001-04-08  2:12                     ` Larry Hazel
2001-04-08 12:12                       ` Ayende Rahien
2001-04-09 16:20                         ` Larry Hazel
2001-04-10  2:38                           ` Ayende Rahien
2001-04-10  3:25                             ` James Rogers
2001-04-08 22:18                       ` Brian Rogoff
2001-04-09 15:14                         ` Ted Dennison
2001-04-09 17:23                           ` Brian Rogoff
2001-04-09 18:23                             ` Laurent Guerby
2001-04-09 19:15                               ` Brian Rogoff
2001-04-10 18:21                                 ` Laurent Guerby
2001-04-10 19:44                                   ` Brian Rogoff
2001-04-11 18:03                                     ` Laurent Guerby
2001-04-11 18:33                                       ` Samuel T. Harris
2001-04-14  0:06                                         ` Robert A Duff
2001-04-12  1:42                                       ` Mike Silva
2001-04-12  2:38                                       ` Brian Rogoff
2001-04-12 23:23                                         ` Laurent Guerby
2001-04-13  2:44                                           ` Brian Rogoff
2001-04-11 13:24                                   ` Ayende Rahien
2001-04-11 13:14                                     ` Mats Karlssohn
2001-04-11 15:08                                       ` Ayende Rahien
2001-04-11 21:42                                       ` Fraser Wilson
2001-04-12 23:55                                         ` Robert A Duff
2001-04-10  2:12                               ` Robert A Duff
2001-04-10  3:47                                 ` Brian Rogoff
2001-04-10 13:40                                 ` Ada keywords (was: Re: newbie can't get exceptions to work!) Marin David Condic
2001-04-10 14:26                                   ` Jean-Pierre Rosen
2001-04-09 20:49                             ` newbie can't get exceptions to work! Ted Dennison
2001-04-09 21:44                               ` Brian Rogoff
2001-04-09 21:59                                 ` Ted Dennison
2001-04-10  2:54                                   ` Ayende Rahien
2001-04-10 14:00                                     ` Ted Dennison
2001-04-10 17:44                                     ` Fraser Wilson
2001-04-10  6:59                               ` Mats Karlssohn
2001-04-10 14:18                                 ` Ted Dennison
2001-04-10 16:27                                   ` Mark Biggar
2001-04-11 11:55                                     ` Mats Karlssohn
2001-04-11 14:34                                       ` Samuel T. Harris
2001-04-11 15:50                                         ` Pat Rogers
2001-04-12  6:27                                         ` Mats Karlssohn
2001-04-11 11:49                                   ` Mats Karlssohn [this message]
2001-04-11 15:38                                     ` Robert A Duff
2001-04-13 16:12                             ` Matthew Woodcraft
2001-04-10  1:41                   ` Robert A Duff
2001-04-10  3:03                     ` James Rogers
2001-04-10  3:58                       ` Brian Rogoff
2001-04-10 21:48                         ` Ted Dennison
2001-04-11 15:09                           ` Ayende Rahien
2001-04-11 21:57                             ` James Rogers
2001-04-11 23:13                               ` Brian Rogoff
2001-04-12  6:33                                 ` Mats Karlssohn
2001-04-12 16:38                                   ` Brian Rogoff
2001-04-17  7:04                                     ` Mats Karlssohn
2001-04-17  9:08                                       ` Jean-Pierre Rosen
2001-04-12 15:16                               ` Ted Dennison
2001-04-12 21:22                                 ` James Rogers
2001-04-10  4:26                     ` Brian Rogoff
2001-04-11 15:30                       ` Robert A Duff
2001-04-11 17:33                         ` Brian Rogoff
2001-04-10  1:26               ` Robert A Duff
2001-04-10  2:11                 ` Brian Rogoff
2001-04-14  0:00                   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2001-04-05  5:26 Christoph Grein
replies disabled

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