You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For many refactoring schemes, you'll want to define variables or functions in one header and use them in the other, e.g.
// header1.wpplvara=1;
// header2.wpplvarb=a+1
and then b is assigned to 2 in your main code.
Currently, whether this works or not depends entirely on the order that you write the two files in package.json. The order written above works, because header1.wppl is appended first, but if you swap the order, e.g.
The way we handle dependencies between webppl headers should be order-independent, and would optimally be able to handle mutual dependencies as well, e.g. if header1.wppl also defined a variable c in terms of b
The text was updated successfully, but these errors were encountered:
I think we'd be best off emulating node's require to make dependencies between .wppl (and also .js) files explicit. See my proposal here.
However, in the meantime, relying on the order in package.json doesn't seem terrible. Have you run into cases where this is a serious obstacle? (We should document it, though.)
I agree that's the best solution. I've always felt uncomfortable calling functions that are defined in some .wppl header, since it's not obvious from reading the code which package they come from, or what header inside that package...
My problem was just that I didn't realize the order mattered, so no I haven't run into any cases where (intentionally) relying on order is a serious obstacle. It's just not obvious from the package documentation.
In our basic package system, you can include a list of webppl header files in your
package.json
file:For many refactoring schemes, you'll want to define variables or functions in one header and use them in the other, e.g.
and then
b
is assigned to2
in your main code.Currently, whether this works or not depends entirely on the order that you write the two files in
package.json
. The order written above works, becauseheader1.wppl
is appended first, but if you swap the order, e.g.then
b
isNaN
in the main code.The way we handle dependencies between webppl headers should be order-independent, and would optimally be able to handle mutual dependencies as well, e.g. if
header1.wppl
also defined a variablec
in terms ofb
The text was updated successfully, but these errors were encountered: