Hello, Zhu Zihao <all_but_l...@163.com> writes:
> Philip McGrath <phi...@philipmcgrath.com> writes: > >> Oh, wow. I definitely had not realized that, *even inside a declarative >> module*, a reference to a variable with no statically visible definition >> would semantically be a dynamic lookup in a mutable environment at >> runtime (rather than a compile-time error), though I do see now that >> `info guile declarative` does indeed say that marking a module as >> declarative "applies only to the subset of top-level definitions that >> are themselves declarative: those that are defined within the >> compilation unit, and not assigned (‘set!’) or redefined within the >> compilation unit." > > It depends on how you reference to it. If a variable is referenced in > the same module, it'll be inlined if it's small enough. > > If you reference it from another module, it'll do something like > module-ref instead (works like non-declarative binding) > >> This seems like a big barrier to cross-module inlining, though IIUC Guile >> currently doesn't do much of that by default (maybe for this reason). > > Guile 3.0.8 comes to rescue. It works by rewrite the `define-module` > call and attach the tree-il of some bindings on it. > > For details, read the blog post authored by Andy Wingo > > https://wingolog.org/archives/2021/05/13/cross-module-inlining-in-guile Thanks for the interesting read (nice writing from Wingo, as usual :-)). Maxim