Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear API for Emitter constructor #300

Open
Geod24 opened this issue Jul 27, 2022 · 1 comment
Open

Unclear API for Emitter constructor #300

Geod24 opened this issue Jul 27, 2022 · 1 comment

Comments

@Geod24
Copy link
Member

Geod24 commented Jul 27, 2022

/**
* 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.

@Herringway
Copy link
Member

I have absolutely no idea... but I believe this library was either a pyyaml port or inspired by it, so the answer might be found there.

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

No branches or pull requests

2 participants