Skip to content

Unclear API for Emitter constructor #300

Description

@Geod24

/**
* Construct an emitter.
*
* Params: stream = Output range to write to.
* canonical = Write scalars in canonical form?
* indent = Indentation width.
* lineBreak = Line break character/s.
*/
this(Range stream, const bool canonical, const int indent, const int width,
const LineBreak lineBreak) @safe
{
states_.reserve(32);
indents_.reserve(32);
stream_ = stream;
canonical_ = canonical;
nextExpected!"expectStreamStart"();
if(indent > 1 && indent < 10){bestIndent_ = indent;}
if(width > bestIndent_ * 2) {bestWidth_ = width;}
bestLineBreak_ = lineBreak;
analysis_.flags.isNull = true;
}

@WebFreaK remarked that (on L176):

why are the given in values ignored in other cases? shouldn't this rather be using contracts?

The parameters in question are not documented either.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions