Commit Graph

17 Commits

Author SHA1 Message Date
Dave Abrahams
47eea01ab8 [stdlib] Eager non-verbatim bridging
Trying to lazily compute bridge results and cache them isn't going to
work, because there's no place to efficiently invalidate the cache in
cases like this:

  func f(a: NSArray) {
    for i in 0...a.count {
      println(a.objectAtIndex(i)) // Fills up the cache
    }
  }

  var message = ["hello", "world"]
  f(message)
  message[0] = "goodbye, cruel" // need a cache invalidation or else
  f(message)                    // ...this prints "hello\nworld\n"

Since we need C performance for subscript assignment, we just can't
afford to do anything extra there.

Instead, when the element type isn't "Bridged Verbatim," just eagerly
convert it to an NSArray.

Swift SVN r17722
2014-05-08 23:02:08 +00:00
Dave Abrahams
dea14570b9 [stdlib] Array doc adjustment
We were wishfully thinking that we could convert all NSArrays lazily.
However, since non-class/existential types are supposed to have a
statically-knowable efficient representation we need an eager conversion
in those cases.

Swift SVN r17538
2014-05-06 07:52:58 +00:00
Dave Abrahams
555674633a [stdlib] Array bridging specification tweaks
Chris suggested that we should lazily typecheck each element when an
NSArray is downcast to Array<T>.  That sounded like a good idea, and
along the way we decided to simplify the implementation and spec by not
bending over backwards to allow broken duck-typing to work for pure ObjC
classes.

Swift SVN r17468
2014-05-05 17:52:58 +00:00
Michael Gottesman
1e7d7fb85f Revert "[stdlib] Array bridging specification tweaks"
This reverts commit r17408.

Swift SVN r17417
2014-05-05 04:05:36 +00:00
Dave Abrahams
a86aecd6fe [stdlib] Array bridging specification tweaks
Chris suggested that we should lazily typecheck each element when an
NSArray is downcast to Array<T>.  That sounded like a good idea, and
along the way we decided to simplify the implementation and spec by not
bending over backwards to allow broken duck-typing to work for pure ObjC
classes.

Swift SVN r17408
2014-05-04 23:16:06 +00:00
Dave Abrahams
dd6b0f7144 [stdlib] More Array doc updates
There's little point in allowing Array<T> to have both direct and
indirect representations when T can be a class type.  Let's drop the
branch cost and generate less code.

Swift SVN r17353
2014-05-04 01:32:54 +00:00
Dave Abrahams
18d12fa234 [stdlib] One more note about Array casting
Swift SVN r17324
2014-05-03 19:51:52 +00:00
Dave Abrahams
5e045b4453 [stdlib] Limit array casts to Array<T>
There's no need to support up- or down-casts for NativeArray<T> or
Slice<T>.  Slice might turn out to be easy, but we don't have time right
now.  Doing it for NativeArray<T> would have efficiency costs that we
don't want to pay.

Swift SVN r17323
2014-05-03 19:49:53 +00:00
Dave Abrahams
9cf3eefb8c [stdlib] Array bridging doc update
This thing is freakin' complicated!  We're going to have to find a
reasonable subset to implement for WWDC.

Swift SVN r17308
2014-05-03 03:53:55 +00:00
Dave Abrahams
2c0a803afe [docs] Updated information on Array casts
Swift SVN r17303
2014-05-03 02:07:14 +00:00
Dave Abrahams
a3bc9b6cb0 [stdlib] Array doc update
Swift SVN r17302
2014-05-03 02:07:14 +00:00
Dave Abrahams
98274bd5d3 [docs] Update Arrays.rst
This is a partial update.  We need to decide how to rework array
up-/down-casting to account for value semantics changes.  Will post to
the list.

Swift SVN r17254
2014-05-02 16:30:14 +00:00
Ted Kremenek
5ad769ec0b Rename the BridgedToObjectiveC protocol to _BridgedToObjectiveC or _BridgedToObjC.
For now we're going to keep BridgedToObjectiveC as a private internal
implementation detail.  Adding the "_" prefix marks it as internal.

Implements <rdar://problem/16736672>.

Swift SVN r16921
2014-04-27 06:07:25 +00:00
Dave Abrahams
06e720257e [stdlib] Array docs: use normal bullets
The funny bullets used by our stylesheet don't paste well into emails.
Also, clean up an editorial comment

Swift SVN r16185
2014-04-10 23:37:24 +00:00
Dave Abrahams
2da97e2736 [stdlib] Array docs: correctness fix
Optional<T>.map doesn't unwrap inner optionals, so have to rephrase.

Swift SVN r16184
2014-04-10 23:18:26 +00:00
Dave Abrahams
ecda8ab966 [stdlib] Array docs: typo fix
Swift SVN r16182
2014-04-10 23:13:15 +00:00
Dave Abrahams
38d73b2b96 [stdlib] Initial docs for the new Array design
Swift SVN r16181
2014-04-10 23:10:33 +00:00