Skip to content

TSCBasic: deprecate <<< operator #413

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

Merged
merged 1 commit into from
Apr 26, 2023
Merged

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Apr 21, 2023

Since TSCBasic has become a kitchen sink for multiple types and functions, it's important to be able to selectively import those. It is done with import struct, import func, and similar statements. Unfortunately, this doesn't work for operators, which means you have to import the whole module when you need access just to a single operator. This inadvertently pollutes the environment of available symbols, which is undesirable.

By deprecating the operator and adding a send(_:) function on WritableByteStream we allow selectively importing this functionality without importing the whole module.

This also brings the API closer to Swift conventions, which in my understanding don't favor use of operators for stream I/O. Looks like <<< was initially brought over to TSC as a C++ idiom.

@MaxDesiatov MaxDesiatov requested a review from abertelrud as a code owner April 21, 2023 12:16
@MaxDesiatov MaxDesiatov self-assigned this Apr 21, 2023
Since TSCBasic has become a kitchen sink for multiple types and functions, it's important to be able to selectively import those. It is done by `import struct` and similar statements. Unfortunately, this doesn't work for operators, which means you have to import the whole module when you need access just to a single operator. This inadvertently pollutes the environment of available symbols, which is undesirable.

By deprecating the operator and adding a `send(_:)` function on `WritableByteStream` we allow selectively importing this functionality.
@MaxDesiatov MaxDesiatov force-pushed the maxd/deprecate-output-operator branch from 35a261b to 6aa85be Compare April 21, 2023 12:17
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci clean test

@MaxDesiatov
Copy link
Contributor Author

MaxDesiatov commented Apr 21, 2023

SourceKit-LSP/SwiftSyntax CI breakage looks unrelated

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test macos

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

is it time to deprecate ByteStream? this predates much of swift maturing on non-DArwin platforms and I am not sure it is still required

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test macos

@MaxDesiatov
Copy link
Contributor Author

MaxDesiatov commented Apr 21, 2023

is it time to deprecate ByteStream? this predates much of swift maturing on non-DArwin platforms and I am not sure it is still required

I hope it is, but it's used in a bunch of places in SwiftPM like logging that relies on ThreadSafeOutputByteStream. Would we want a replacement of that type to rely on Swift Concurrency instead and become an actor? Would logging become async then?

Not something we have to have answers for this particular PR, these are more long-term questions.

@MaxDesiatov MaxDesiatov requested a review from tomerd April 21, 2023 18:21
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test macos

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test macos

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) April 26, 2023 11:52
@MaxDesiatov MaxDesiatov merged commit 78e53cb into main Apr 26, 2023
MaxDesiatov added a commit to swiftlang/swift-package-manager that referenced this pull request Apr 26, 2023
MaxDesiatov added a commit to swiftlang/swift-package-manager that referenced this pull request Apr 26, 2023
MaxDesiatov added a commit to swiftlang/swift-package-manager that referenced this pull request Apr 27, 2023
MaxDesiatov added a commit to swiftlang/swift-package-manager that referenced this pull request Apr 27, 2023
Addresses some of the deprecations introduced in swiftlang/swift-tools-support-core#413

Also using this as an opportunity to use string interpolation and raw string literals to make this more readable.
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

Successfully merging this pull request may close these issues.

3 participants