REJOIN ugliness and the usefulness of tests


Short summary: We need more tests and should ask ourselves if they make sense.

Discovering a bug in REJOIN motivated me to create some tests for it (it had none) and the outcome of that was I was quite surprised at how weird REJOIN's current behaviour is.

Though I have used REJOIN extensively in my R2 code, I must be using it in a way that avoids some behavioural ugliness.

Have a look at the tests added to Ren-c for REJOIN.

Thought train:

  • Why is REJOIN so weird?
  • Maybe I don't want to REJOIN in my code anymore if it is that odd.
  • I only became aware of how weird it is by writing the tests.
  • Tests serve as documentation and can therefore draw attention to weirdness perhaps motiving a better solution.
  • I wonder if it would be useful to formalise the "tests as documentation" notion?
1 Like
It's Time To JOIN Together
Ren-C's eloquence in the face of FizzBuzz

And REJOIN suggests that you join pieces of something that broke back together again. Most of us have started out using JOIN to put things together, then found out it did not do what they wanted and so they got pointed to REJOIN that does the expected thing.
Long story short, JOIN is seldom used and we all use REJOIN all the time, where we initially want to read just JOIN.

The name REJOIN is unlucky too because in an alphabetic list of functions it does not show up next to JOIN and will easily be overlooked, where JOIN-ALL will be found because is is right underneath JOIN.
Perhaps a longer name like JOIN-ON-FIRST will be better describing that the JOIN will result in something of the TYPE! of the first item.
SPACED and UNSPACED, I will have to get used to those. Perhaps I am better of with alias JOIN-SPACED and JOIN-UNSPACED for those.

About the code of REJOIN in there are still a few unfamiliar functions for me in there (CHAIN, SPECIALIZE) so I cannot directly say what is wrong in its definition.


The link I gave was to the commit.

You can find the current REJOIN here, which I have written to emulate R3, it is not using the newer functions.


Well, now you know why I made SPACED and UNSPACED!

1 Like