This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass | |
| class Empty: | |
| pass | |
| @dataclass | |
| class Node: | |
| color: str | |
| left: object | |
| val: object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <memory> | |
| #include <variant> | |
| #include <iostream> | |
| struct Engine { | |
| int fuel; | |
| Engine(int fuel_) : fuel(fuel_) {} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <memory> | |
| #include <variant> | |
| #include <iostream> | |
| struct Spaceship { | |
| std::variant<bool, std::string> v; | |
| Spaceship(std::variant<bool, std::string> v_) : | |
| v(std::move(v_)) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <memory> | |
| #include <variant> | |
| #include <iostream> | |
| struct Engine { | |
| int fuel; | |
| Engine(int fuel_) : fuel(fuel_) {} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <memory> | |
| #include <variant> | |
| #include <iostream> | |
| struct Engine { | |
| int fuel; | |
| Engine(int fuel_) : fuel(fuel_) {} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Navigation: ~Copyable { | |
| var antenna: Bool | |
| } | |
| struct Engine: ~Copyable { | |
| var warp_coils: [Int] | |
| } | |
| enum Variant: ~Copyable { | |
| case navigation(Navigation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <memory> | |
| #include <variant> | |
| #include <iostream> | |
| struct Engine { | |
| int fuel; | |
| Engine(int fuel_) : fuel(fuel_) {} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class Engine { | |
| var fuel = 100 | |
| } | |
| class Spaceship { | |
| var engine = Engine() | |
| } | |
| func accelerate(_ ship: Spaceship) { | |
| let engine = ship.engine // Race: read | |
| // literally no field access |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <memory> | |
| #include <thread> | |
| struct Engine { | |
| int fuel = 100; | |
| }; | |
| struct Spaceship { | |
| std::shared_ptr<Engine> engine = std::make_shared<Engine>(); | |
| }; | |
| void accelerate(std::shared_ptr<Spaceship> ship) { | |
| std::shared_ptr<Engine> engine = ship->engine; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Navigation: ~Copyable { | |
| var antenna: Bool | |
| } | |
| struct Engine: ~Copyable { | |
| var fuel: Int | |
| } | |
| enum Variant: ~Copyable { | |
| case navigation(Navigation) |
NewerOlder