Skip to content

Comments

[trivial] Either make private or document undocumented public symbols in stdio#4789

Merged
andralex merged 1 commit intodlang:masterfrom
JackStouffer:package2
Sep 23, 2016
Merged

[trivial] Either make private or document undocumented public symbols in stdio#4789
andralex merged 1 commit intodlang:masterfrom
JackStouffer:package2

Conversation

@JackStouffer
Copy link
Contributor

No description provided.

@9il
Copy link
Member

9il commented Sep 15, 2016

What the reason of that change? This will break existing code

std/stdio.d Outdated
be compatible with the access attributes of the handle. Windows only.

Throws: $(D ErrnoException) in case of error.
Throws: $(D ErrgnoException) in case of error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow, I don't think that you meant to insert a g here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

std/stdio.d Outdated
}
// no UTF checking
/// Implements `opApply` `foreach` support but with no UTF checking
int opApplyRaw(D)(scope D dg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's just intended to be used by opApply and should not be treated as public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will mark as private

@jmdavis
Copy link
Member

jmdavis commented Sep 15, 2016

What the reason of that change? This will break existing code

If something isn't documented, then it doesn't exist. Anyone who uses an undocumented symbol has no guarantees that their code won't be broken by changes to it later.

@9il
Copy link
Member

9il commented Sep 15, 2016

If something isn't documented, then it doesn't exist. Anyone who uses an undocumented symbol has no guarantees that their code won't be broken by changes to it later.

I don't agree. No guarantees, but it still exists. And an engineer do not need to spend time by copypasting code

@JackStouffer
Copy link
Contributor Author

These symbols were completely undocumented. The only way people were using these is if they found them by pure chance or they were looking at Phobos code. Either way, they aren't officially part of the Phobos API, so this is not a breaking change

@codecov-io
Copy link

codecov-io commented Sep 15, 2016

Current coverage is 88.86% (diff: 100%)

Merging #4789 into master will decrease coverage by <.01%

@@             master      #4789   diff @@
==========================================
  Files           121        121          
  Lines         74221      74221          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          65959      65958     -1   
- Misses         8262       8263     +1   
  Partials          0          0          

Powered by Codecov. Last update 3142577...121af02

@JackStouffer
Copy link
Contributor Author

FIxed

@9il
Copy link
Member

9il commented Sep 15, 2016

The only real way to understand phobos is to look into its code. Our documentation is not so good

@jmdavis
Copy link
Member

jmdavis commented Sep 15, 2016

The only real way to understand phobos is looking into its code. Out documentation is not so good

It's as good or better than most of the documentation for C++'s standard library, and you don't go looking though the STL and decide to use undocumented symbols do you?

@9il
Copy link
Member

9il commented Sep 15, 2016

The only real way to understand phobos is looking into its code. Out documentation is not so good
It's as good or better than most of the documentation for C++'s standard library, and you don't go looking though the STL and decide to use undocumented symbols do you?

I don't. STL has much more users and online activity. STL and Boost sources looks terrible for me. Phobos sources are readable and clean.

@jmdavis
Copy link
Member

jmdavis commented Sep 15, 2016

I don't. STL has much more users and online activity. STL and Boost sources looks terrible for me. Phobos sources are readable and clean.

So, because there are fewer people to ask questions about Phobos, and it's actually readable, you think that folks should be able to expect to rely on undocumented symbols? I really don't think that that's reasonable. If they were intended to be part of the public API, they would be documented. The fact that they're public is either a mistake or a workaround for a problem and not because it's something that anyone should be using.

@jmdavis
Copy link
Member

jmdavis commented Sep 15, 2016

@JackStouffer It looks like you have some trailing whitespace, and the auto-tester doesn't like that.

@WalterBright
Copy link
Member

I think that code was written by @andralex I think he should comment on whether they are meant to be public or not.

@WalterBright
Copy link
Member

@JackStouffer Please in the future use more descriptive branch names than things like package2, which would be helpful when looking at https://auto-tester.puremagic.com/pulls.ghtml?projectid=1

This could be called stdio-private, for example. Something to jog the memory on what it is about.

@andralex
Copy link
Member

There are two kinds of undocumented public symbols: (a) some that were inadvertent, (b) some that used to be documented and have been shunned by being left out there but undocumented in order to not break code.

I encourage making those in category (a) private, but (b)s should be left alone (at best with a comment indicating they're to stay put. @JackStouffer could you do some detective work on the file history to see which is which? Thx!

@JackStouffer
Copy link
Contributor Author

JackStouffer commented Sep 19, 2016

Here's my philosophy:

  1. If something is public, then it's meant to be used by the programmer, unless it's specifically set for deprecation
  2. If something is not meant to be used by the programmer, it should be private (again, baring deprecation)
  3. If it's meant to be used by the programmer, then the programmer should know about it, i.e. it should be documented

I believe these changes fall in line with that. The structs were never meant to be used directly; you're supposed to use the factory functions.

@schuetzm
Copy link
Contributor

I expect category (b) to have a (non-ddoc) comment stating that the symbols are there for legacy reasons.

@andralex
Copy link
Member

Auto-merge toggled on

@andralex andralex merged commit c940f5a into dlang:master Sep 23, 2016
@ghost
Copy link

ghost commented Nov 11, 2016

breakage confirmed since 2.072. DFMT uses a few of these symbols. See https://github.com/Hackerpilot/dfmt/blob/master/src/dfmt/main.d#L118

@qchikara
Copy link
Contributor

I suggest that these should be deprecated BEFORE private.
If we can make it private, we could also rename to _privateName and add a temporary alias orgName with the attr deprecated, then eventually omit such alias.

@mihails-strasuns
Copy link

@qchikara that is indeed a correct (and required) approach.

John-Colvin pushed a commit to John-Colvin/phobos that referenced this pull request Dec 8, 2016
This reverts commit c940f5a, reversing
changes made to aaf31b5.

Fixes issue 16682
@JackStouffer JackStouffer deleted the package2 branch May 22, 2017 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants