<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/143469>143469</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Compiler extension for Rust-like using syntax
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mikomikotaishi
      </td>
    </tr>
</table>

<pre>
    I do not know if requests/suggestions for compiler extensions are accepted, but I would like to suggest adding Rust-style `using` statements as a language extension for Clang. What I mean by that is, in Rust the `use` statement has much more versatility and ergonomics than in C++. Example:
```rust
use std::env::Args;
use std::fs::{File, FileType};
use std::io; 
use std::os::{linux::{fs::MetadataExt, process::PidFd}, unix::net::Incoming, windows::{io::BorrowedSocket, ffi::EncodeWide}};
use std::thread::*;
```
If we wanted to load the same symbols into scope in C++, the equivalent code in ISO C++ (if C++ had the same standard library structure as Rust), would be:
```cpp
using std::env::Args;
using std::fs::File;
using std::fs::FileType;
namespace io = std::io;
using std::os::linux::fs::MetadataExt;
using std::os::linux::process::PidFd;
using std::os::unix::net::Incoming;
using std::os::windows::io::BorrowedSocket;
using std::os::windows::ffi::EncodeWide;
using namespace std::thread;
```
The proposed syntax in C++ (again assuming the C++ standard library was equivalent to the Rust standard library), would instead be:
```rust
using std::env::Args;
using std::fs::{File, FileType};
using std::io; 
using std::os::{linux::{fs::MetadataExt, process::PidFd}, unix::net::Incoming, windows::{io::BorrowedSocket, ffi::EncodeWide}};
using std::thread::*;
```
For instance, if we were using the actual C++ standard library, we could instead write `using std::chrono::*;` instead of `using namespace std::chrono;`. Or, instead being able to write `using std::ranges;` to do:
```cpp
using std::ranges;

// We can write ranges::min() instead of std::ranges::min()
int minimum = ranges::min({33, 54, 13, 802, 7, 61});
```
Again, I do not know if this is an appropriate place to request/suggest compiler/language extensions, but such a feature would be greatly beneficial for improving ergonomics especially as `using` statements are much more viable with the addition of modules to C++, which do not export `using` statements by default unlike headers.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUlktvIrkTwD-NuZQGNYbwOHCAzCDl8Nf8tTPSnKvb1d3euO0ePyB8-1UZCBBIJtrbSgn9cD1dvy4XhqAbS7QUD2vx8HWAKbbOLzv97Pg_og6tHpRO7ZdPoBxYF-HZuh3oGjz9ThRiEHITUtNQiNrZALXzULmu14Y80EskG_J79ARYVdRHUkI-QpkiPMHOJaPA6GeC6OBoB1ApbRv4K4X4JcS9IRDTIgVtGzEtIESM1JGNATAAgkHbJGzo7C0H8cjvh_CrRXbUEVoo9xD5UQeOQNvsAWJ7tE9X1qHFAF2qWuicJ9iSDxi10XEPaBWQb5x1na4C27Rs7VHItZDrIXx7wa43JMYrUazEtDj8-RSiKFYpEISoeHG8Irs93Kx8E8R4_Xa9DoermK032hCHzdef-57E7OsdBe3EeA1v37qzGaNtenl9Otn_H0VUGPHbS2QfvXcVhePa_7XaKPYmHyFZfVS2FA83T7ZyHZdGPsJOW-V2Z2ccDd-unfduR-qHq54pe6hrfVj6Ziun6JdWOaG7OcXWEx7vhVwdJF63VRSrpxp2BDu0kRRzZByqXNaAHUHYd6UzAbRlxCrX00WxOBaWpN9Jb9Fw3Tkelnj68f0kBULOdf361F6Zj2gVeqa49Oj3EKJPVUzMe8iECbnIm5NZL99iUfV9TpiJ_5iLK4lT5TIWfxLIvGQhix2FHisC7UCMv74h59bMCZ0Lbu5B80nVO2B9pPkRbh_pXXH4DoSf1r-H6oXyeUdvgH3L6c-W-NPqXSAFYW8jvlygyJBhg9oChpA4xwzZafWGsx2GS2yjy-K5pb2VvSJQ2xAJ75D42qD-JYofN6krlYs2dbcA_6FGdRX_H1vVxvlcALRV3ih9aF3kCQ6muIZYxYTm3crnBAiqq2ruvI7nc_IcUdV6Z91VRNPiVcvVZ5U7IJ-UWWcI3_3h2Dzhw0pYmnx0v-feo20oHL1GB8p9pv2dtYosLDdCbuAXQYX26Ook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