JuliaCollections / JuliaCollections/DataStructures.jl

fill!(::CircularBuffer) has a surprising definition

Open
#447 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
745
Forks
261
PR merge metrics
No merged PRs in 30d

Description

The definition of fill!(::CircularBuffer, val)

    fill!(cb, data)
Grows the buffer up-to capacity, and fills it entirely.
It doesn't overwrite existing elements.

is at odds with the Base definition

  fill!(A, x)

  Fill array A with the value x. If x is an object reference, all elements
  will refer to the same object. fill!(A, Foo()) will return A filled with the
  result of evaluating Foo() once.

When I think of the English word "fill", the CircularBuffer definition makes more sense, but clearly it's too late to change Base, and it seems bad to have the same function with two different meanings. I propose that, by analogy with isempty/empty!, we could rename the above fill! definition to full!, to match with isfull. @femtotrader

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named in the issue. Start by locating the CircularBuffer definitions of fill! and isfull, then compare their behavior with Julia Base's fill! semantics. Done requires an agreed API direction and consistent naming or compatibility behavior, with the affected documentation and tests updated accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.