Skip to content

Conversation

@gildor478
Copy link
Member

No description provided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's simpler to write:

OpamPackage.Set.(add nv (union (get_dependencies nv) set))

@samoht
Copy link
Member

samoht commented Nov 6, 2013

Woops... Thanks for the fix! Can you just correct that minor remark ?

@samoht
Copy link
Member

samoht commented Nov 7, 2013

After some thoughts I'm not totally convinced by your fix. I think it will be safer to simply add nv to the set returned by get_dependencies (not sure why you've added the if .. then .. else construct there: this works only if we are lucky with the order in which we traverse the already computed set).

@gildor478
Copy link
Member Author

If nv is already in the set, it means that it has already been visited, so there is no reason to go through it once again. That is the reason of the if then else.

Adding the element to the get_dependencies, change slightly the meaning of the function since it will return not only the deps but the deps and itself (but that may be fine).

Doing it without the if then else, is fine. BUT not good in term of complexity because the set keep expanding with each recursive call and even if you already have computed deps you will try again to get it again and again...

But this is just my 2 cents and my 2 min hack done done late at night, I may have some bugs here.

@samoht
Copy link
Member

samoht commented Nov 7, 2013

If nv is already in the set, it means that it has already been visited, so there is no reason to go through it once again. That is the reason of the if then else.

Well not necessary; if nv is in the set it can also be a dependency of something we already have visited.

@gildor478
Copy link
Member Author

Oh god, you are right in fact. I was mislead but the fact that we have only one set.

We should visited and to_visit set, and the end condition is that to_visit set must be empty.

@gildor478
Copy link
Member Author

will fix that tonight, but the former algo was wrong anyway and the complexity argument stands.

@gildor478
Copy link
Member Author

I think this is fixed, please take another look.

samoht added a commit that referenced this pull request Nov 13, 2013
Really compute transitive dependencies in opam_mk_repo (Close: #976).
@samoht samoht merged commit 8d7dddd into ocaml:master Nov 13, 2013
@samoht
Copy link
Member

samoht commented Nov 13, 2013

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants