- Timestamp:
- Mar 16, 2017, 4:50:08 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 395fc37, 64ac636, ef42b143
- Parents:
- 2f26687 (diff), d6d747d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- doc/proposals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/proposals/concurrency/thePlan.md
r2f26687 r1fbab5a 7 7 8 8 _Phase 2_ : Minimum Viable Product 9 Monitor type and enter/leave mutex member routines9 done - Monitor type and enter/leave mutex member routines 10 10 Monitors as a language feature (not calling enter/leave by hand) 11 11 Internal scheduling -
doc/proposals/flags.md
r2f26687 r1fbab5a 69 69 In each of the cases above, `FOO` could be replaced by `(BAR | BAZ)` to do the same operation or test on multiple flags at once. 70 70 71 ### Alternative/Additional Features ### 72 73 #### User-defined enum discriminant iterator #### 74 It may be useful to provide a more general method for changing the enum discriminant assignment function, e.g. the flag enum discriminants could be defined by something like the following: 75 76 ``` 77 enum(@ << 1) TCP_Flags { // each discriminant is left-shifted by 1 from the previous 78 FIN = 0x1, // first flag is 1 79 SYN, 80 ACK, 81 ... 82 } 83 ``` 84 85 #### Member expression for enums #### 86 As a more ergonomic way to set and unset enum flags, we could define a member expression for flags enums. Since only unions and structs can have member expressions now, this change would be backwards compatible. Basically, given a `FunFlags f`, `f.FOO` would return a proxy object which could be implicitly converted to `bool` (with semantics `f & FOO`, i.e. "check if `FOO` is set on `f`"), as well as having `bool` assigned to it (with semantics `f |= FOO` on true or `f -= FOO` on false, i.e. "set or unset `FOO` on `f` as appropriate"). With this member function, the operations above can be expressed as follows (possibly more ergonomically): 87 88 ``` 89 FunFlags f = some_val(); 90 if ( f.FOO ) { sout | "f has FOO set" | endl; } 91 f.FOO = true; // set FOO 92 f.FOO = false; // unset FOO 93 f.FOO = ! f.FOO; // toggle FOO 94 ``` 95 71 96 ### Related Work ### 72 97 C# has the [`[Flags]`][1] enum attribute, but their proposal does not go as far; specifically, the flag discriminants must be manually specified, and they do not automatically implement the bitwise operators on the flags.
Note: See TracChangeset
for help on using the changeset viewer.