Skip to content

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Jul 5, 2017

#5083 (comment)

Yeah but it doesn't make sense otherwise, does it? Seems antithetical to deprecate something for everyone else but not ourselves.
Any reason not to enable -de on the test suite then?

CC @CyberShadow

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.



/*
@safe pure @nogc unittest
Copy link
Member

Choose a reason for hiding this comment

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

Wasn't it possible to mark the unittest as deprecated, which allows testing deprecated code? Or was I dreaming?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, that does seem to work!



/*
@safe pure @nogc unittest
Copy link
Member

Choose a reason for hiding this comment

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

Nope, that does seem to work!

@wilzbach wilzbach force-pushed the deprecation-halt branch from 6369d3b to 16b9188 Compare July 5, 2017 16:28
@wilzbach
Copy link
Contributor Author

wilzbach commented Jul 5, 2017

Wasn't it possible to mark the unittest as deprecated, which allows testing deprecated code? Or was I dreaming?
Nope, that does seem to work!

Wow sweat - it works on my local machine :)

Copy link
Contributor Author

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

Not sure how to handle the unittests in std.uni which access private symbols. I undocumented them for now to see whether it would pass all stages.

}

///
@safe pure unittest
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CsvReader is private

///
@safe unittest
{
assert(unicode.Cyrillic.intersect('-').byInterval.empty);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

generated/linux/release/64/publictests/std_uni.d(132): Deprecation: std.uni.InversionList!(GcPolicy).InversionList.intersect(U)(U rhs) if (isCodepointSet!U) is not visible from module std_uni


///
@system pure unittest
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

generated/linux/release/64/publictests/std_uni.d(192): Deprecation: std.uni.BitPacked(T, ulong sz) if (isIntegral!T || is(T : dchar)) is not visible from module std_uni

}

///
@safe unittest
Copy link
Contributor Author

Choose a reason for hiding this comment

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

generated/linux/release/64/publictests/std_uni.d(242): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(243): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(244): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(245): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(250): Deprecation: std.uni.Utf16Matcher!().Impl!(1, 2).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni

@CyberShadow
Copy link
Member

I undocumented them for now to see whether it would pass all stages.

Yep, I think undocumenting them is the way to go for now. If the examples are not actually usable by users, then it's misleading to even show them. CI will prevent adding documented unittests that aren't usable outside the module, right?

@CyberShadow
Copy link
Member

CC @DmitryOlshansky

@wilzbach
Copy link
Contributor Author

wilzbach commented Jul 5, 2017

If the examples are not actually usable by users, then it's misleading to even show them. CI will prevent adding documented unittests that aren't usable outside the module, right?

Yup. Any idea on how we could tackle the deprecation warnings for Windows?
The problem is that toUTF8/16 got only partially deprecated and these are legit uses:

std\windows\registry.d(48): Deprecation: function std.utf.toUTF8 is deprecated - To be removed November 2017. Please use std.utf.encode instead.
std\windows\registry.d(48): Deprecation: function std.utf.toUTF16 is deprecated - To be removed November 2017. Please use std.utf.encode instead.
std\file.d(2971): Deprecation: function std.utf.toUTF8 is deprecated - To be removed November 2017. Please use std.utf.encode instead.

Maybe by(W)Char.array.assumeUnique?

@CyberShadow
Copy link
Member

Correct me if I'm wrong, but couldn't those uses simply be replaced with std.conv.to!string / to!wstring?

@wilzbach
Copy link
Contributor Author

wilzbach commented Jul 5, 2017

Correct me if I'm wrong, but couldn't those uses simply be replaced with std.conv.to!string / to!wstring?

Let's see what the auto-tester says ;-)

@jmdavis
Copy link
Member

jmdavis commented Jul 5, 2017

Yep, I think undocumenting them is the way to go for now. If the examples are not actually usable by users, then it's misleading to even show them.

Continuing to show the examples makes it easier for folks to figure out how the functions work so that they can more easily figure out how to fix their code so that it's not using the deprecated functions anymore - especially in cases where we're not providing a simple replacement (as is the case here). So, I think that it's better to keep the examples in the documentation if we can.

@CyberShadow
Copy link
Member

CyberShadow commented Jul 5, 2017

Continuing to show the examples makes it easier for folks to figure out how the functions work so that they can more easily figure out how to fix their code so that it's not using the deprecated functions anymore - especially in cases where we're not providing a simple replacement (as is the case here). So, I think that it's better to keep the examples in the documentation if we can.

In this particular case the problem was that the examples were using private symbols, so the examples were never actually usable unable only by accident. I think this coincides with enabling deprecation errors because previously it was possible to use private symbols in other modules under some circumstances.

To see for yourself, copy one of the unittests undocumented here to a new D file and try to compile them. E.g.:

import std.uni;

void main()
{
	auto m = utfMatcher!char(unicode.Number);
	string square = "";
	// about sub-matchers
	assert(!m.subMatcher!(2,3,4).test(square)); // ASCII no covered
	assert(m.subMatcher!1.match(square)); // ASCII-only, works
	assert(!m.subMatcher!1.test(square)); // unicode '²'
	assert(m.subMatcher!(2,3,4).match(square));  //
	assert(square == "");
	wstring wsquare = "";
	auto m16 = utfMatcher!wchar(unicode.Number);
	// may keep ref, but the orignal (m16) must be kept alive
	auto bmp = m16.subMatcher!1;
	assert(bmp.match(wsquare)); // Okay, in basic multilingual plan
	assert(bmp.match(wsquare)); // And '²' too
}

This gives deprecation warnings because subMatcher is a private symbol, so there is something wrong either with the unittest or the declaration of subMatcher.

@jmdavis
Copy link
Member

jmdavis commented Jul 5, 2017

Ah, okay. That makes sense then.

@jmdavis
Copy link
Member

jmdavis commented Jul 5, 2017

fgsfds

Did github not let you provide an empty comment when dismissing your review?

@CyberShadow
Copy link
Member

Exactomundo.

@CyberShadow
Copy link
Member

Some remaining ones (from the autotester):

std\file.d(2647): Deprecation: function std.utf.toUTF8 is deprecated - To be removed November 2017. Please use std.utf.encode instead.
std\file.d(3433): Deprecation: Comparison between different enumeration types `Flag` and `Flag`; If this behavior is intended consider using `std.conv.asOriginalType`
std\file.d(4289): Deprecation: function std.utf.toUTF8 is deprecated - To be removed November 2017. Please use std.utf.encode instead.
std\datetime\timezone.d(2994): Deprecation: function std.utf.toUTF16 is deprecated - To be removed November 2017. Please use std.utf.encode instead.
std\windows\charset.d(117): Deprecation: function std.utf.toUTF8 is deprecated - To be removed November 2017. Please use std.utf.encode instead.

private import std.conv;
private import std.string;
private import std.utf;
private import std.windows.syserror;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Btw what's the reason for private imports? Aren't they private by default?

Copy link
Member

Choose a reason for hiding this comment

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

I think very very old versions of D (well into 0.x) had imports public by default, like C header files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow -> #5553

@wilzbach
Copy link
Contributor Author

wilzbach commented Jul 5, 2017

Yeah it's finally passing on Windows:

image

(I rebased my three attempts to get Windows working into one commit)

@CyberShadow
Copy link
Member

LGTM. @DmitryOlshansky Please have a look at the std.uni unit tests when you find the time.

@dlang-bot dlang-bot merged commit e0fc939 into dlang:master Jul 5, 2017
@ghost
Copy link

ghost commented Jul 6, 2017

Pardon me but why did you ( @wilzbach @CyberShadow @jmdavis ) make and/or accept this completely stupid thing ? Now when the goal of a DMD pull request is to deprecate something everything goes red and the auto tester cant be used anymore to fix the PR (e.g platform specific failure missed locally) because the tests don't run anymore.

see the tests here dlang/dmd#6925

👏

@ghost ghost mentioned this pull request Jul 6, 2017
@wilzbach wilzbach deleted the deprecation-halt branch July 6, 2017 11:35
@wilzbach
Copy link
Contributor Author

wilzbach commented Jul 6, 2017

Now when the goal of a DMD pull request is to deprecate something everything goes red and the auto tester cant be used anymore to fix the PR (e.g platform specific failure missed locally) because the tests don't run anymore.

That's exactly why we made this PRs in case you haven't noticed as there have been continuous incidents (aka regressions) of deprecations within Phobos showing up in the user build due to Posix being the most popular developer platform.

See also: #5083 (comment)

@ghost
Copy link

ghost commented Jul 6, 2017

But it can't work. Phobos and DMD are two different repositories !

@mathias-lang-sociomantic
Copy link
Contributor

I wholeheartedly agree with @bbasile here, but for different reason. If you have code which have a certain behavior, and you want to deprecate one symbol, but keep the same behavior, there are places where you have no choices but to use a deprecated symbol.

One example which happened recently is here. I ended up using a hack with extern(C), but really we should have a way to allow library users to use deprecated feature when they really need to.

@CyberShadow
Copy link
Member

CyberShadow commented Jul 6, 2017

I wholeheartedly agree with @bbasile here, but for different reason. If you have code which have a certain behavior, and you want to deprecate one symbol, but keep the same behavior, there are places where you have no choices but to use a deprecated symbol.

I suggest to wait until we run into a situation that warrants reconsidering this before reverting it.

One example which happened recently is here. I ended up using a hack with extern(C), but really we should have a way to allow library users to use deprecated feature when they really need to.

Why not:

  1. Move the implementation of the public function that is to be deprecated to a private / package xxxImpl function
  2. Add a public deprecated wrapper or alias which forwards to the xxxImpl function
  3. Change all internal references of xxx to xxxImpl ?

@mathias-lang-sociomantic
Copy link
Contributor

Why not: [...]

It will work, but you are basically duplicating all your public symbols, as you need to do it for everything you are deprecating. It feels very wrong that you have to do such a large patchset for a simple deprecation. But yes, it's possible if you are willing to go through that pain.

@CyberShadow
Copy link
Member

I don't know; it seems more wrong to me to be hypocritical about deprecations.

If you absolutely need to use public symbols from inside your implementations so much that deprecating such public symbols becomes an issue, it may indicate that there is a problem with the separation of interface and implementation in your code base. Futhermore, projects that wish to use the -de switch will not be able to directly use (e.g. via rdmd) libraries which rely on this behavior.

Anyway, the requirements and internal structure of Ocean and Phobos are undoubtedly very different, so I suggest to wait and see if/when we run into an actual problem.

@PetarKirov
Copy link
Member

@mathias-lang-sociomantic I don't understand your reaction. What's the problem with making deprecations errors inside Phobos? How does this effect anyone else? Of course, if we reach a place where this is a problem, this could easily be disabled, but for the time being, I believe that the more rigorous testing is well worth it.

@bbasile what's the problem with fixing the errors caused by deprecations first and then merging PRs that actually introduce those deprecations? Either way, the hardest thing is getting the proposal to deprecate something accepted rather than fixing the stuff themselves, IMO (though your specific case is a bit more involved because people were casting string literals to static arrays).

@CyberShadow
Copy link
Member

Case in point:
https://issues.dlang.org/show_bug.cgi?id=17621

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.

6 participants