Replies: 4 comments 4 replies
-
| Having it be   | 
Beta Was this translation helpful? Give feedback.
-
| I voted for  words: std::vector<std::string> = ("Adam", "Betty");
// for enumerate(words) do ([i, word]) {            // some destructuring syntax maybe?
// for words | std::views::enumerate do (entry) {   // pipe operator instead
for std::views::enumerate(words) do (entry) {
    i := std::get<0>(entry);
    word := std::get<1>(entry);
    std::cout << i << ": " << word << "\n";
}Not to say that there aren't other cases where  | 
Beta Was this translation helpful? Give feedback.
-
| 
 Yeah, I like the destructuring syntax you suggested. I've been playing around with converting example code from cppreference into Cpp2, and here's another case I came across where the  Cpp2 translation of std::condition_variable example from cppreference#include <thread>  // Not sure yet why this is needed in my Godbolt setup
m: std::mutex = ();
cv: std::condition_variable = ();
data: std::string = ();
ready: bool = false;
processed : bool = false;
worker: () = {
    (copy lk: std::unique_lock = (m))
    {
        cv.wait(lk, :() -> bool = ready);
        std::cout << "Worker is processing data\n";
        data += " after processing";
        processed = true;
        std::cout << "Worker thread signals data processing completed\n";
        _ = lk.mutex();  // Workaround for UFCS and last-use std::move bug
    }
    cv.notify_one();
}
main: () -> int = {
    worker_thd: std::thread = (worker);
    data = "Example data";
    (copy _: std::lock_guard = (m))
    {
        ready = true;
        std::cout << "main() signals data ready for processing\n";
    }
    cv.notify_one();
    (copy lk: std::unique_lock = (m))
    {
        cv.wait(lk, :() -> bool = processed);
        _ = lk.mutex();  // Workaround for UFCS and last-use std::move bug
    }
    std::cout << "Back in main(), data = " << data << '\n';
    worker_thd.join();
    _ = m.native_handle();   // Workaround for UFCS and last-use std::move bug
    _ = cv.native_handle();  // Workaround for UFCS and last-use std::move bug
    return 0;
}The relevant parts look like this: // m: std::mutex = ();
// cv: std::condition_variable = ();
(copy lk: std::unique_lock = (m))
{
    cv.wait(lk, :() -> bool = some_condition);
} | 
Beta Was this translation helpful? Give feedback.
-
| Thanks, everyone! I'll close this as "status quo" for now, and we can always reopen it again in the future if we get new information. | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
[edited to add Case 4]
This poll arises from #1000, and concerns statement scope parameters, such as a
counterfor a loop or :The question is, should the default
/*...*/parameter passing qualifier beinorcopy?If
in(the current status quo):in valwould be the default)inout valcopy countercopy valand is not consistent with a local variableval := value;which meanscopyIf
copy(as it has been in the past before this commit):in valinout valcopy counterwould be the default)copy valwould be the default) and is consistent with a local variableval := valuewhich meanscopy16 votes ·
Beta Was this translation helpful? Give feedback.
All reactions