Changeset 1fbab5a for doc

Mar 16, 2017, 4:50:08 PM (7 years ago)
Rob Schluntz <rschlunt@…>
ADT, aaron-thesis, arm-eh, ast-experimental, 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
395fc37, 64ac636, ef42b143
2f26687a (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.

Merge branch 'master' of

2 edited


  • doc/proposals/concurrency/

    r2f26687a r1fbab5a  
    88_Phase 2_ : Minimum Viable Product
    9 Monitor type and enter/leave mutex member routines
     9done - Monitor type and enter/leave mutex member routines
    1010Monitors as a language feature (not calling enter/leave by hand)
    1111Internal scheduling
  • doc/proposals/

    r2f26687a r1fbab5a  
    6969In each of the cases above, `FOO` could be replaced by `(BAR | BAZ)` to do the same operation or test on multiple flags at once.
     71### Alternative/Additional Features ###
     73#### User-defined enum discriminant iterator ####
     74It 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:
     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        ```
     85#### Member expression for enums ####
     86As 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):
     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        ```
    7196### Related Work ###
    7297C# 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.