comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Parser interface design
Date: Thu, 07 Apr 2011 23:09:09 +0100
Date: 2011-04-07T23:09:09+01:00	[thread overview]
Message-ID: <m21v1dvhmi.fsf@pushface.org> (raw)
In-Reply-To: slrnips50m.2fnq.lithiumcat@sigil.instinctive.eu

Natasha Kerensikova <lithiumcat@gmail.com> writes:

> Now at least I understand the idea of using generics instead:
>
>    generic
>       with function Emphasis (Contents: String) return String is <>;
>       with function Normal_Text (Contents: String) return String is <>;
>       with function Paragraph (Contents: String) return String is <>;
>    function Parser (Renderer: Renderer_Callbacks; Input: String)
>      return String;

I think the Renderer argument shouldn't be there?

Don't see what's wrong with providing a No_Op function which returns its
input unchanged? unless you do something specific for a null?

> However I am a bit skeptical about whether or not generics is actually a
> better approach than the record of accesses. Generics is certainly a
> higher-level feature than record and access, but I don't think that's
> enough to prefer one over the other. On the other hand, I understand the
> criticism of generics posted here (with my apologies for not remember
> who had which arguments), with all the problems caused by the function
> not actually existing until it's instanced.

Not sure I remember that, generics aren't _that_ bad!

> I believe such generics to be a lesser evil than generic types, and
> similarly I believe access to subprograms to be lesser evils than access
> to data. However I wouldn't be surprised if parser instantiation means
> duplicating the code for each parser. Even if it's the compiler that
> actually performs the code duplication, I'm not very at ease with it.

I'd let it get on with it. You're unlikely to have many instantiations
in one program, I'd have thought?

Personally I tend to feel uneasy with access-to-subprogram.

> All in all, I can't find any argument in favor of replacing the record
> of accesses with the generic approach.

Nor can I.


In your original post, you said

> I also though of implementing each callback once, as standalone
> procedures, and then use tagged procedures to call them, but that
> seems very messy too.

Presumably you'll implement each callback once, as a standalone function,
and pop them in the record/call the generic as appropriate?




  parent reply	other threads:[~2011-04-07 22:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06 10:11 Parser interface design Natasha Kerensikova
2011-04-06 12:17 ` Georg Bauhaus
2011-04-07 18:56   ` Natasha Kerensikova
2011-04-08 11:49     ` Stephen Leake
2011-04-06 12:20 ` Dmitry A. Kazakov
2011-04-07 19:14   ` Natasha Kerensikova
2011-04-07 20:31     ` Dmitry A. Kazakov
2011-04-08 13:51       ` Natasha Kerensikova
2011-04-08 14:21         ` Dmitry A. Kazakov
2011-04-12 15:58           ` Natasha Kerensikova
2011-04-12 17:14             ` Dmitry A. Kazakov
2011-04-06 15:51 ` Georg Bauhaus
2011-04-07 19:44   ` Natasha Kerensikova
2011-04-07 20:52     ` Dmitry A. Kazakov
2011-04-07 22:09     ` Simon Wright [this message]
2011-04-08 14:03       ` Natasha Kerensikova
2011-04-08 19:06         ` Jeffrey Carter
2011-04-08 19:59         ` Simon Wright
2011-04-12 16:13           ` Natasha Kerensikova
2011-04-12 17:22             ` Dmitry A. Kazakov
2011-04-12 19:02               ` Simon Wright
2011-04-13  8:20                 ` Natasha Kerensikova
2011-04-13  8:37                   ` Dmitry A. Kazakov
2011-04-13 11:06                     ` Georg Bauhaus
2011-04-13 12:46                       ` Dmitry A. Kazakov
2011-04-13 22:33                   ` Randy Brukardt
2011-04-14  6:55                     ` Natasha Kerensikova
2011-04-15  0:22                       ` Randy Brukardt
2011-04-12 21:54               ` Randy Brukardt
2011-04-07 22:13     ` Georg Bauhaus
2011-04-08 15:30       ` Natasha Kerensikova
2011-04-07  0:36 ` Randy Brukardt
2011-04-08 11:16 ` Brian Drummond
2011-04-19  9:08 ` Natasha Kerensikova
2011-04-19 12:35   ` Ludovic Brenta
2011-04-20 10:44     ` Brian Drummond
2011-04-19 17:28   ` Jeffrey Carter
replies disabled

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