Skip to content

Conversation

@mb64
Copy link

@mb64 mb64 commented Apr 24, 2021

Use single-sided unification rules for foldl/4 so that something like foldl(not_a_list, Goal, In, Out) is an exception instead of silently failing. This would be a breaking change.

Some unresolved questions:

  • Is it a good change? I had to debug some code today where this would have told me the problem right away. However, it is a breaking change, so there is a chance that someone relies on this behavior.
  • foldl/N where N > 4? I originally also wanted to change the other foldls, but decided against it, since it would break all the code that uses foldl like a kind of "maplist with state".
  • scanl? I think this change might be significantly more breaking for scanl than for foldl, so I didn't change scanl.
  • Unit tests: I didn't add any, since I'm not familiar with the test setup, but with guidance I would be happy to add one.

@JanWielemaker
Copy link
Member

Thanks. This breaks test src/Tests/library/test_apply.pl:117 😢 We could argue this to be a buggy test. We could also argue that non-equal length lists for foldl/5+ should return an error. I'm not sure. Maybe you would like to discuss this on Discourse?

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