You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to roy...@googlegroups.com
Hi everyone,
at the moment it doesn't seem to be possible to compile multiple files which depend on each other without explicitly providing the ordering.
I created two files declare.roy and consume.roy. consume.roy uses a type declared in declare.roy.
This works: ./roy declare.roy consume.roy
This fails: ./roy consume.roy declare.roy
This also fails since the files are enumerated alphabetically: ./roy *.roy
Am I missing something? Would it be feasible to implement an algorithm which determines dependencies and compiles the files in the right order? Maybe something simple like a "require" statement at the beginning of the file? IIUC when using Roy modules I'd also have to compile the modules in the correct order.
TIA for any insights!
-- Andreas
Andreas Hartmann
unread,
Oct 10, 2013, 7:20:38 PM10/10/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to roy...@googlegroups.com
I have added a little function to node_repl.js which allows to add dependencies. There are certainly more elegant solutions, but this does the trick for me for the moment. No circular dependency detection.
Declare dependencies using comments:
// require other_roy_file
Here's the code:
function sortByDependencies(srcFiles) {
function dependencies(src) { var source = getFileContents(src); var depsMatches = source.match(/^\/{2,}\s*require\s+([\w\.\/]+)\s*$/mg); return depsMatches === null ? [] : depsMatches.map(function(d) { return /^\/{2,}\s*require\s+([\w\.\/]+)\s*$/.exec(d)[1]; }); }
function depends(src1, src2) { return _.contains(src1.deps, src2.name); }
function cmp(src1, src2) { if (depends(src1, src2)) return 2; else if (depends(src2, src1)) return 1; else return 0; }
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to roy...@googlegroups.com
There was a typo in the cmp function:
function cmp(src1, src2) { if (depends(src1, src2)) return 1; else if (depends(src2, src1)) return -1; else return 0; }
Andreas Hartmann
unread,
Oct 10, 2013, 8:56:11 PM10/10/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to roy...@googlegroups.com
This only worked for very simple setups since transitive dependencies were not considered. I have added a more sophisticated version with circular dependency detection to my fork: