Coroutines and Structured Concurrency in PracticeA task can only run when it’s being awaited by another task https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/Sketching an API Taskgreet() { cout co_return co_await resolveOn(name, "1.1.1.1"); }); co_return visit(identity{}, v); }Structured concurrency Tasks naturally form a "call tree" • coroutines • leaf awaitables (sleeping, I/O, cancel()? No longer a simple allOf()Dynamic allOf() We have created a fundamental primitive of structured concurrency • nursery in Python trio • task group in Python asyncio • task scope in Rust • coroutine 0 码力 | 103 页 | 1.98 MB | 6 月前3
C++26 Previewcollections, new ranges, language features 4Outline of the talk I Language & Library debugging structured bindings Language Templates Misc Contracts Reflection 5Outline of the talk II Library: string is_debugger_present is_replaceable 13Structured Bindings 14use as conditions in if, while, for, and switch statements success evaluation prior to destructuring blog: P0963 Structured binding declaration as a condition while, for, and switch statements success evaluation prior to destructuring blog: P0963 Structured binding declaration as a condition https://mariusbancila.ro/blog/2024/09/06/whats-new-in-c26- part-1/0 码力 | 118 页 | 2.02 MB | 6 月前3
Named Optional Parameters - JavaScript Stylefunction logger({one, two, three} = {}) { // in signature: = {} provides destructure // similar to structured binding // first check for what would be a “compiler” error if ( one == null ) throw new Error("i data members only ▪designated initializers -- initializing a struct with: { .field = value } ▪structured binding -- disaggregating a struct with: auto& [field1, field1] = myStruct ▪function overloading - noDefaultExists; Speed speed; }; Inside of processCarStateTransition the struct argument is spread with structured binding. Answer processCarStateTransition(const PathToChangingStatus& path) { auto& [car, roadType0 码力 | 1 页 | 3.17 MB | 6 月前3
Back to Basics: Algebraic Data TypesgenerateDefaultCert(); std::cout << "Made cert for host " << std::get<0>(hct) << "\n"; // C++17 structured binding auto [host, cert, ttl] = generateDefaultCert(); std::cout << "Made cert for host " << host = generateDefaultCert(); std::cout << "Made cert for host " << info.host << "\n"; // C++17 structured binding still permits this auto [host, cert, ttl] = generateDefaultCert(); std::cout << "Made cert0 码力 | 73 页 | 267.05 KB | 6 月前3
Back to Basics: Lambda ExpressionsmyLamb = [ ] (auto var1, int var2) { return var1 + var2; } 42Lambda Expressions ● Structured Bindings ○ structured bindings make it easier to access elements of tuples, arrays, and other compound types // line A auto myLamb = [x] () { return x + 7; }; // line B ○ capturing a structured binding was deemed invalid according to the standard, so line B does not compile as of C++17 ○ workaround:0 码力 | 48 页 | 175.89 KB | 6 月前3
Julia 1.11.4names.) Since Julia allows numeric literals to be juxtaposed with identifiers as coefficients, this binding suffices to provide convenient syntax for complex numbers, similar to the traditional mathematical languages.) For example, in the function function f(x, y) x[1] = 42 # mutates x y = 7 + y # new binding for y, no mutation return y end The statement x[1] = 42 mutates the object x, and hence this change passed by the caller for this argument. On the other hand, the assignment y = 7 + y changes the binding ("name") y to refer to a new value 7 + y, rather than mutating the original object referred to by0 码力 | 2007 页 | 6.73 MB | 3 月前3
Julia 1.11.5 Documentationnames.) Since Julia allows numeric literals to be juxtaposed with identifiers as coefficients, this binding suffices to provide convenient syntax for complex numbers, similar to the traditional mathematical languages.) For example, in the function function f(x, y) x[1] = 42 # mutates x y = 7 + y # new binding for y, no mutation return y end The statement x[1] = 42 mutates the object x, and hence this change passed by the caller for this argument. On the other hand, the assignment y = 7 + y changes the binding ("name") y to refer to a new value 7 + y, rather than mutating the original object referred to by0 码力 | 2007 页 | 6.73 MB | 3 月前3
Julia 1.11.6 Release Notesnames.) Since Julia allows numeric literals to be juxtaposed with identifiers as coefficients, this binding suffices to provide convenient syntax for complex numbers, similar to the traditional mathematical languages.) For example, in the function function f(x, y) x[1] = 42 # mutates x y = 7 + y # new binding for y, no mutation return y end The statement x[1] = 42 mutates the object x, and hence this change passed by the caller for this argument. On the other hand, the assignment y = 7 + y changes the binding ("name") y to refer to a new value 7 + y, rather than mutating the original object referred to by0 码力 | 2007 页 | 6.73 MB | 3 月前3
Whats in a Name? Whats a Name in? - Walter E. Brown - CppCon 2020underscore plus most characters from ISO/IEC 10646). � “An en:ty is a value, object, reference, structured binding, func`on, enumerator, type, class member, bit-field, template, template specializa`on, namespace0 码力 | 7 页 | 4.37 MB | 6 月前3
Julia 1.11.0-rc4 Documentationnames.) Since Julia allows numeric literals to be juxtaposed with identifiers as coefficients, this binding suffices to provide convenient syntax for complex numbers, similar to the traditional mathematical languages.) For example, in the function function f(x, y) x[1] = 42 # mutates x y = 7 + y # new binding for y, no mutation return y end The statement x[1] = 42 mutates the object x, and hence this change passed by the caller for this argument. On the other hand, the assignment y = 7 + y changes the binding ("name") y to refer to a new value 7 + y, rather than mutating the original object referred to by0 码力 | 1985 页 | 6.67 MB | 10 月前3
共 165 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17













