<commit_before>2013-11-13
----------

* Objective-C-compatible protocols can now contain optional
  requirements, indicated by the @optional attribute:

    @class_protocol @objc protocol NSWobbling {
      @optional def wobble()
    }

  A class that conforms to the NSWobbling protocol above can (but does
  not have to) implement wobble. When referring to the 'wobble'
  method for a value of type NSWobbling (or a value of generic type
  that is bounded by NSWobbling), the result is an optional value
  indicating whether the underlying object actually responds to the
  given selector, using the same mechanism as messaging 'id'. One can
  use '!' to assume that the method is always there, '?' to chain the
  optional, or conditional branches to handle each case distinctly:

    def tryToWobble(w : NSWobbling) {
      w.wobble()   // error: cannot call a value of optional type
      w.wobble!()  // okay: calls -wobble, but fails at runtime if not there
      w.wobble?()  // okay: calls -wobble only if it's there, otherwise no-op
      if w.wobble {
        // okay: we know -wobble is there
      } else {
        // okay: we know -wobble is not there
      }
    }

* Enums from Cocoa that are declared with the NS_ENUM macro are now imported
  into Swift as Swift enums. Like all Swift enums, the constants of the Cocoa
  enum are scoped as members of the enum type, so the importer strips off the
  common prefix of all of the constant names in the enum when forming the Swift
  interface. For example, this Objective-C declaration:

    typedef NS_ENUM(NSInteger, NSComparisonResult) {
      NSOrderedAscending,
      NSOrderedSame,
      NSOrderedDescending,
    };

  shows up in Swift as:

    enum NSComparisonResult : Int {
      case Ascending, Same, Descending
    }

  The enum cases can then take advantage of type inference from context, as in:

    var foo: NSNumber = 1
    var bar: NSNumber = 2
    switch foo.compare(bar) {
    case .Ascending:
      println("ascending")
    case .Same:
      println("same")
    case .Descending:
      println("descending")
    }

2013-11-06<commit_msg>Show the Objective-C version of NS_ENUM usage for comparison.<commit_after>2013-11-13
----------

* Objective-C-compatible protocols can now contain optional
  requirements, indicated by the @optional attribute:

    @class_protocol @objc protocol NSWobbling {
      @optional def wobble()
    }

  A class that conforms to the NSWobbling protocol above can (but does
  not have to) implement wobble. When referring to the 'wobble'
  method for a value of type NSWobbling (or a value of generic type
  that is bounded by NSWobbling), the result is an optional value
  indicating whether the underlying object actually responds to the
  given selector, using the same mechanism as messaging 'id'. One can
  use '!' to assume that the method is always there, '?' to chain the
  optional, or conditional branches to handle each case distinctly:

    def tryToWobble(w : NSWobbling) {
      w.wobble()   // error: cannot call a value of optional type
      w.wobble!()  // okay: calls -wobble, but fails at runtime if not there
      w.wobble?()  // okay: calls -wobble only if it's there, otherwise no-op
      if w.wobble {
        // okay: we know -wobble is there
      } else {
        // okay: we know -wobble is not there
      }
    }

* Enums from Cocoa that are declared with the NS_ENUM macro are now imported
  into Swift as Swift enums. Like all Swift enums, the constants of the Cocoa
  enum are scoped as members of the enum type, so the importer strips off the
  common prefix of all of the constant names in the enum when forming the Swift
  interface. For example, this Objective-C declaration:

    typedef NS_ENUM(NSInteger, NSComparisonResult) {
      NSOrderedAscending,
      NSOrderedSame,
      NSOrderedDescending,
    };

  shows up in Swift as:

    enum NSComparisonResult : Int {
      case Ascending, Same, Descending
    }

  The enum cases can then take advantage of type inference from context.
  In Objective-C, you would write:

    NSNumber *foo = [NSNumber numberWithInt: 1];
    NSNumber *bar = [NSNumber numberWithInt: 2];

    switch ([foo compare: bar]) {
    case NSOrderedAscending:
      NSLog(@"ascending\n");
      break;
    case NSOrderedSame:
      NSLog(@"same\n");
      break;
    case NSOrderedDescending:
      NSLog(@"descending\n");
      break;
    }

  In Swift, this becomes:

    var foo: NSNumber = 1
    var bar: NSNumber = 2

    switch foo.compare(bar) {
    case .Ascending:
      println("ascending")
    case .Same:
      println("same")
    case .Descending:
      println("descending")
    }

2013-11-06
{'fraction_non_alphanumeric': 0.07378972062273406, 'fraction_numerical': 0.008104073363190446, 'mean_word_length': 2.8474159146841673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2742008', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1333, 'n_words': 584}