Couldn't we use mixins in run-time?
Walker22
alexwhite197952 at gmail.com
Sat Apr 24 12:36:31 UTC 2021
On Thursday, 22 April 2021 at 22:07:09 UTC, H. S. Teoh wrote:
> On Thu, Apr 22, 2021 at 09:01:45PM +0000, Dukc via
> Digitalmars-d wrote:
>> On Wednesday, 21 April 2021 at 07:50:35 UTC, rempas wrote:
>> > I'm really wondering, what stops us about using mixins in
>> > run-time? I'm really interested on learning how they work.
>> > For my understating, the write the code for use in
>> > compile-time and then the whole things is compiled. However,
>> > I'm really wondering what stops us for writing the code and
>> > compiling it at run-time like it's an interpreter. Anyone
>> > that can explain how things work to me?
>>
>> Having runtime mixins in the default language would the
>> downside that the D runtime would have to include a D
>> interpreter. No thanks.
>>
>> Note though, I said in the default language. Having a separate
>> D interpreter that would be called as an external program
>> would be different thing altogether. To some extent, you can
>> already do that by feeding your runtime scripts to rdmd.
>
> I've written programs that invoke `dmd` to compile fragments of
> D code. It does work, and dmd is fast enough that the pause is
> often not noticeable (unless you're doing it in a tight inner
> loop). The fragments are compiled into shared objects and
> dynamically loaded and executed by the program. Ostensibly,
> one could employ a similar mechanism to dynamically compile
> parts of a program at runtime and integrate these bits of code
> into itself.
>
> This does introduce a dependency on the availability of a D
> toolchain in the user's environment, though. This may or may
> not be desirable, depending on what you're trying to do. Plus,
> there may be licensing issues if you decide to distribute a dmd
> toolchain along with your program. But it can probably be
> done, should you wish to do so.
>
> Having said that, though, I'm also unsure about the wisdom of
> supporting this as a built-in feature in D. That would require
> shipping a runtime interpreter or a complete D toolchain in
> every program, which seems like overkill for a rather narrow
> use case.
>
>
> T
Thanks https://www.myaarpmedicare.onl/
More information about the Digitalmars-d
mailing list