Mimi Framework

Improve readability of connect_param syntax?

This is not an important question, but I’ve been doing lots of replication code lately so thinking about how others read my code has been on my mind. The connect_param! syntax always felt a bit difficult to follow (in terms of thinking which components are giving vs. receiving output). I think it makes it a little tricky for Mimi beginners and non-coders to follow along too.

Would it be possible to instead have something like:

connect_param!(m, (:giving_comp, :param) -> (:receiving_comp, :param))

Something like that just seems easier to quickly look at and understand what’s going on. But again, very minor point.

It’s a great point, and we’ve had back and forth discussion about what syntax makes sense. I feel similarly to you about the order, but there’s also the argument that what you really are doing is tying the :recieving_comp parameter TO the :giving_comp parameter so the directionality in our current syntax is more accurate in that sense of what depends on what. Changing the ordering now could be confusing, but we do also have this syntax now that at least puts the pairs together better.

connect_param!(mymodel, :TargetComponent=>:parametername, :SourceComponent=>:variablename)

@lrennels and I just talked about this. The problem probably is that the term connect doesn’t clarify what is being connected here exactly.

I think our best bet is to think of some alternative word instead of connect that makes it clearer in what way the data flows… Crudely something like move_data_from_to would probably be a lot clearer when it comes to understand the flow direction here.

@davidanthoff @lrennels Yea I’m indifferent to how the syntax is structured, I just wanted to point out the potential source of confusion. Here’s the example that actually made me post this issue (from my own code):

connect_param!(m, :rf_total, :rf_CH₄, :rf_ch4, :rf_CH4)

I also can never remember which way it goes, so this is definitely a more than legit complaint :slight_smile:

1 Like