Adding circular-buffer to Raku stream?

Hello

I was wondering how someone could add circular-buffer in a testable way to the tasks. I had some play-around with objects, but it seems quite hash and not TIMTOWTDI to enforce a strict interface to all users. But maybe that also opens up new perspectives to some …

Has anyone done anything on this already?

Here my initial attempt.

That way it would be easy to test, but not easy to digest, I guess.

Any thoughts?

Thank you for your attempt. I have opened a pull request to implement the exercise using an adaptation of your solution.

1 Like

Thank you for adding the exercise.

I just tried to solve the exercise in the Browser. I am wondering, if we need to put an is export onto the Exeptions (as exercise is marked “easy”). Furthermore I noticed that I can not throw inside a PRE{} in order to pass the test. I have to do it outside

(From an accademic point of view) PRE/POST are very interesting features of Raku, perhaps we can promote them by adjusting the test?

Exception checks in tests can be complicated at times. In previous exercises I used to just test for Exception, but the problem with that was newer users would write code which would raise an exception, but with an exception thrown because the actual exception was not implemented correctly. I also try to avoid steering to much into having solutions implemented in a specific way.

You can still use PRE/POST by adding the following to your solution:
my class X::Phaser::PrePost is X::CircularBuffer::BufferIsFull is X::CircularBuffer::BufferIsEmpty {}

Eventually there will be a concept exercise with more detail on exceptions.