NetLogo / NW-Extension

This is the NetLogo Network Extension. For general information about NetLogo, see:
http://ccl.northwestern.edu/netlogo/
Other
62 stars 25 forks source link

Should path primitives report `false` instead of empty list when no path is available? #154

Closed nicolaspayette closed 8 years ago

nicolaspayette commented 9 years ago

See https://stackoverflow.com/questions/29943474/shortest-path-query-returning-empty-list/ for context.

There, @SethTisue makes the excellent point that:

It does seem dodgy that an empty list might mean "no path", or it might mean "zero length path because source equals destination" [nw:path-to turtle 3] of turtle 3.

This would be a breaking change. And things have been that way forever. But I think it's worth considering.

qiemem commented 9 years ago

Hmm, interesting. Reporting false doesn't strike me as superior enough to warrant breaking backwards compatibility, especially since returning false also isn't an entirely satisfactory solution.

SethTisue commented 9 years ago

opinion: I think this is a bug, plain and simple, and there is no excuse for just leaving it the way it is forever. The current behavior is just plain wrong.

If you aren't willing to break compatibility here in the 5.2.x series, how about for 5.3?

frankduncan commented 9 years ago

From http://ccl.northwestern.edu/netlogo/docs/dictionary.html#create-link-from

"a node cannot be linked to itself"

making me wonder if the concept of a path from a turtle to itself is actually a valid path in terms of netlogo. Maybe the correct thing to do here is error instead of returning anything.

edit: Though I suppose "paths from agents to themselves results in undefined behavior" would satisfy the current implementation.

qiemem commented 9 years ago

@frankduncan The idea is that the path from a turtle to itself is, in fact, empty, as it doesn't require traversing any links. You don't need self-loops for this. The current behavior for nw:path-to self is correct.

qiemem commented 8 years ago

Given that a major version change is coming up, I'm going to go ahead and fix this.