Steven and Stefan, thank you both for your input; really great community
here.

I do already have said data structure for the reaction network, and guess I
just need to spend some time thinking about how to build the interpreter
that you suggest. Somehow it feels easier and more natural to produce the
string that represents the ODE, than to actually implement the equivalent
function...I know that sounds backwards, but I'm struggling a little bit to
see a path towards the interpreter. Anyhow it sounds like an interpreter
will pay dividends in terms of the speed of the code, and the general
"correctness" of methodology. Plus I implemented the anonymous function
approach above and it caused a pretty catastrophic "signal (6): Aborted"
crash of julia0.5rc2...so not really moving in the correct direction with
the metaprogramming.  I am sure if I spend a little time thinking deeply I
will see how to build the interpreter.


On Fri, Aug 12, 2016 at 2:18 PM, Stefan Karpinski <[email protected]>
wrote:

> I can understand the allure of mutating and evaling code for evolutionary
> programming, but I think it's fundamentally not the right way to go. You
> probably want to write some kind of simple, high-performance interpreter
> for a custom data structure, which is essentially what Steven is
> suggesting. Otherwise you're going to really spend a lot of time in eval.
>
> On Fri, Aug 12, 2016 at 3:12 PM, Steven G. Johnson <[email protected]>
> wrote:
>
>>
>>
>> On Friday, August 12, 2016 at 1:35:11 PM UTC-4, Garrett Jenkinson wrote:
>>>
>>> I have written a bit of a hack of a library for evolutionary
>>> computation, where I continually evolve a system of "cells" that have
>>> different reaction networks governed by ordinary differential equations.
>>> Basically, when I need to solve the ODE for a cell, I have it generate a
>>> string that after parse/eval'ing is a function to be passed onto ode23s in
>>> ODE.jl for solving.
>>>
>>
>> Why do you need to use parse/eval at all?  Why can't you just write a
>> function that implements your ODE given a data structure representing the
>> reaction network?
>>
>> As a rule of thumb, if you are doing runtime parse/eval, you are usually
>> making a mistake.  (As opposed to compile-time parse/eval, e.g. when a
>> module is loaded; that kind of metaprogramming is quite useful and natural
>> in Julia.  The main exception where runtime parse/eval is appropriate is if
>> you are presenting a user interface where a human can input code
>> expressions to modify your runtime behavior.)
>>
>
>

Reply via email to