comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Plugin-based code
Date: Mon, 4 Jun 2018 17:08:30 -0500
Date: 2018-06-04T17:08:30-05:00	[thread overview]
Message-ID: <pf4d8u$mh4$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 564cec8c-8da9-4e59-a687-5408fd3a429f@googlegroups.com

"mockturtle" <framefritti@gmail.com> wrote in message
news:564cec8c-8da9-4e59-a687-5408fd3a429f@googlegroups.com...
...
>In order to have all the built-in plugins registered in my executable, I
>need to
>"with" them, so that they are linked to my code and the initialization part
>of
>their bodies is elaborated. However, no part of my code call explicitly,
>say,
>SVG_Plotter.  Therefore, my solution is to add something like
>
>  with Plotters.SVG;
>  pragma Warnings(Off, Plotter.SVG);
>
>in the "main." It works, but it leaves me a bit unsatisfied since it seems
>an "hack".

Definitely.

>Also, since no actual code is called directly I am not sure if the binder
>could
>take the liberty of not including them (maybe it cannot, but I am not
>sure).

If the code could be called indirectly (via dispatching, say) it should
remain in any case (at least in a correct compilation system!). Otherwise,
it could get removed. (Janus/Ada does this automatically - it reduces the
size of Claw programs from 2.5 MB to 0.5 MB; GNAT does not to such removal,
to my knowledge - there's some tool you could use to do it.)

I'd expect from your program structure that you are registering routines to
be called via dispatching calls. That should work properly, just with a
"with", even with no direct calls. I used a similar structure in the Claw
builder for registering the supported entities (buttons, edit boxes,
dialogs, main windows, etc.), and didn't have any problems. (Well, I needed
one giant case statement to emulate a factory, 'cause Ada didn't have
anything like that at the time. So the constructor for each type is called
explicitly. But all of the other operations are called only by dispatching.)

                                                         Randy.

Do you have any better solution?

Also, I am not sure if I risk getting in trouble with Elaboration order.  I
think not, but I am not 100% sure.  What do you think?


Thanks,

Riccardo




  parent reply	other threads:[~2018-06-04 22:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 10:29 "Plugin°-based code mockturtle
2018-06-04 11:59 ` Dmitry A. Kazakov
2018-06-04 14:03 ` Dan'l Miller
2018-06-04 22:08 ` Randy Brukardt [this message]
2018-06-05  8:42 ` Brian Drummond
replies disabled

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