[swift-dev] Trying to work out how default parameters work

2015-12-08 Thread Brent Royal-Gordon via swift-dev
My first question is simply this: is this the best place for the sort of question I’m about to ask? Is there an IRC channel or Slack or something where people who are working with Swift’s compiler internals are hanging out? Are people on Twitter (hi, Joe Groff!) going to mind if I pester them wi

Re: [swift-dev] [stdlib] Array.description calls debugDescription on its contents

2015-12-11 Thread Brent Royal-Gordon via swift-dev
>> while I was working on this PR I encountered unexpected behavior from >> Array.description. It iterates over its items and calls debugDescription on >> them. I found it a bit unexpected thus my question here. Is it desired >> behavior? I would expect description and debugDescription call resp

Re: [swift-dev] [stdlib] Array.description calls debugDescription on its contents

2015-12-12 Thread Brent Royal-Gordon via swift-dev
> Nobody should be using '.description' or '.debugDescription' directly > in any case. One should be using String(x) or String(reflecting: x), > because that works with any instances, including those cases when the > runtime will synthesize the string representation for you. It would similarly be

Re: [swift-dev] Brackets as part of typ names / compiler messages

2015-12-18 Thread Brent Royal-Gordon via swift-dev
> I hope that Swift 4.0 will have enough template-like syntax to build > something like a generic matrix that can be used in a typesafe way, but in > the meantime, I wanted to harness the power of unicode to create "class > Matrix«4×4»", which really confused the compiler. > "class Vector🐸" is n

Re: [swift-dev] C-style For Loops

2015-12-19 Thread Brent Royal-Gordon via swift-dev
>> for lat in (CGFloat(-60)...60).by(30) { >> print(lat) >> } >> >> for lat in (CGFloat(-60)..<60).by(30) { >> print(lat) >> } > > This is nice; why don't we put it in the standard library and get rid of the > "stride" methods? One practical reason is that interval.start must always be befo

Re: [swift-dev] C-style For Loops

2015-12-19 Thread Brent Royal-Gordon via swift-dev
>> One practical reason is that interval.start must always be before >> interval.end, so this makes striding in reverse difficult. > > We could declare that negative strides cause us to start at the end rather > than at the start. I've noticed in the past that the Swift standard library does no

Re: [swift-dev] C-style For Loops

2015-12-19 Thread Brent Royal-Gordon via swift-dev
> I personally liked the original free-function syntax—"stride(from: -50, to: > 50, by: 9)". When we got protocol extensions, we decided we'd prefer methods > everywhere except in a few special cases, and this clearly falls outside > those criteria. I don't know about that—in `stride(from: -50

Re: [swift-dev] [Discussion] New refcount representation

2016-03-19 Thread Brent Royal-Gordon via swift-dev
>> I take it the refcount field's pointer is itself considered a weak >> reference, so the weak refcount starts +1 like the unowned refcount does? > > You need to do something to make sure the side allocation is not freed if the > object is live with no weak references to it. Biasing the weak re

Re: [swift-dev] [Discussion] New refcount representation

2016-03-19 Thread Brent Royal-Gordon via swift-dev
This is damned clever. > * Allows inexpensive per-object storage for future features like associated > references or class extensions with instance variables. It sounds like you wouldn't be able to resize an out-of-band refcount allocation once it's been created, though, right? There are pointe

Re: [swift-dev] [swift-users] Collection underestimatedCount() does _?

2016-03-19 Thread Brent Royal-Gordon via swift-dev
> You gave cases for which `underestimatedCount()` is used: >> For sequences with easily-calculated counts, this should give us a size >> that's just right. For sequences where they can kind of estimate the right >> count (for instance, if you're decoding a fixed-size buffer of UTF-8 bytes, >> a

Re: [swift-dev] [Discussion] New refcount representation

2016-03-20 Thread Brent Royal-Gordon via swift-dev
>> You don't talk much about it, but I think you're suggesting that the strong >> and unowned refcounts would still be packed into the same fields. It's worth >> noting that your clever high-bit-indicates-slow-path trick would *not* work >> on the unowned refcount, though that matters less since

Re: [swift-dev] NSProxy dynamic casting to Swift or ObjC class behaves differently

2016-06-08 Thread Brent Royal-Gordon via swift-dev
> In my use case, I have a framework, and I want to switch developer's some > delegate object with my NSProxy standin, listen delegate method myself, then > forward to the developer's original delegate object. > > It was working without any issues for delegate objects which are Objective-C > cl

Re: [swift-dev] Set of "no less than one" member enforced by the compiler

2016-06-26 Thread Brent Royal-Gordon via swift-dev
> Half-digression into relational theory aside, I can’t figure a way to make > the compiler enforce this. An enum is "exactly one", a Set is "zero or more", > a structure or class is "this group", an Optional is "zero or one". You can write an enum that's "one or more": enum OneOrMore {

Re: [swift-dev] Bridging Python Packages to Swift

2016-07-02 Thread Brent Royal-Gordon via swift-dev
> I lack the experience the rest of the people in this list probably have being > an undergraduate student but I would love to participate in this language > because I see its potential. > > With that being said, one of the biggest advantages python has is its > immersive number of packages tha

Re: [swift-dev] Random() in the standard library

2016-07-02 Thread Brent Royal-Gordon via swift-dev
> On Jun 24, 2016, at 6:38 AM, James Andrews via swift-dev > wrote: > > Is there a reason why random() is missing from the standard library? Is > it just a matter of someone implementing it? (Note: I'm just a guy, not someone in a leadership position.) Random number generation is surprisingly

Re: [swift-dev] [RFC] Finer grained OS checks

2016-07-10 Thread Brent Royal-Gordon via swift-dev
> On Jul 7, 2016, at 7:19 PM, Jordan Rose via swift-dev > wrote: > > Finally, in the spirit of “question everything”, is “environment” the right > name for this setting? :-) Also, is "environment" a name we want to take for this particular feature? "Environment" is a broad and general word, a

Re: [swift-dev] Array with associatedtype protocol pattern

2016-07-14 Thread Brent Royal-Gordon via swift-dev
> On Jul 13, 2016, at 11:23 AM, 4 bottiglie g via swift-dev > wrote: > > Hi, i have asked the same question : > Here: https://forums.developer.apple.com/message/153781#153781 > And here : > http://stackoverflow.com/questions/38281800/array-with-associatedtype-protocol > > But it seams like swi

Re: [swift-dev] [swift-evolution-announce] End of source-breaking changes for Swift 3

2016-07-27 Thread Brent Royal-Gordon via swift-dev
> On Jul 27, 2016, at 12:38 PM, Ted Kremenek wrote: > > • SE-0045 - Add scan, prefix(while:), drop(while:), and iterate to the > stdlib The associated bug, SR-1516, is assigned to Russ Bishop, who said in late June that he had the non-lazy versions implemented. -- Brent Royal-Gordon Ar

Re: [swift-dev] [swift-evolution] [Swift 4] Organizing source stability

2016-08-03 Thread Brent Royal-Gordon via swift-dev
> On Jul 29, 2016, at 5:55 PM, Jacob Bandes-Storch via swift-evolution > wrote: > > • a top-of-file "shebang"-style comment indicating the version, > something like //#swift(4), mirroring the "#if swift" syntax `import Swift 3.1`? I think this brings up two interesting questions: * Do

[swift-dev] CGFloat string conformance issue

2017-03-10 Thread Brent Royal-Gordon via swift-dev
I just noticed that CGFloat conforms to CustomStringConvertible, but it should probably conform to LosslessStringConvertible. (Both of its underlying types support the protocol.) Is this something I can submit a PR for, or does it have to come out of the Core Graphics team? -- Brent Royal-Gord

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Brent Royal-Gordon via swift-dev
> On Sep 5, 2017, at 11:59 AM, Jordan Rose via swift-dev > wrote: > > Now, we don't plan to stick to C's layout for structs, even fixed-contents > structs. We'd really like users to not worry about manually packing things > into trailing alignment space. But we still need a way to lay out fiel

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-09 Thread Brent Royal-Gordon via swift-dev
> On Sep 6, 2017, at 9:52 PM, Slava Pestov wrote: > >> On Sep 6, 2017, at 7:57 PM, Brent Royal-Gordon via swift-dev >> mailto:swift-dev@swift.org>> wrote: >> >> This is going against the grain, but I think we should order by name and >> therefore all

Re: [swift-dev] What can you change in a non-exhaustive enum?

2017-10-03 Thread Brent Royal-Gordon via swift-dev
> On Sep 29, 2017, at 6:21 PM, Jordan Rose via swift-dev > wrote: > > It's time for MagicKit 6 to come out, and we're going to add a new SpellKind: > > @available(MagicKit 6) > case summoning > // [charm, curse, hex, blight, jinx, summoning] > > We ship out a beta to our biggest clients, but r

Re: [swift-dev] Rationalizing FloatingPoint conformance to Equatable

2017-10-19 Thread Brent Royal-Gordon via swift-dev
> On Oct 19, 2017, at 4:29 PM, Xiaodi Wu via swift-dev > wrote: > > D) Must floating-point IEEE-compliant equivalence be spelled `==`? > > In my view, this is something open for debate. I see no reason why it cannot > be migrated to `&==` if it were felt that `==` *must* be a full equivalence

Re: [swift-dev] Rationalizing FloatingPoint conformance to Equatable

2017-10-22 Thread Brent Royal-Gordon via swift-dev
> On Oct 21, 2017, at 6:27 PM, Xiaodi Wu via swift-dev > wrote: > > Steve can describe the exact number of additional machine instructions on > each architecture, but from my cursory reading the performance cost is not > good and there's little cleverness to be had. I'm not sure why you think

Re: [swift-dev] "Near-miss" warnings for protocol conformances

2017-11-02 Thread Brent Royal-Gordon via swift-dev
> On Oct 26, 2017, at 9:28 PM, Douglas Gregor via swift-dev > wrote: > > Unlabeled single-value initializers are probably going to cause a number of > false positives, because we can’t figure out which one we meant. When we're dealing with unlabeled initializers, can we use tighter rules? For

Re: [swift-dev] SR-3423 Starter questions

2017-11-09 Thread Brent Royal-Gordon via swift-dev
> On Nov 7, 2017, at 4:18 AM, Mohammed Ennabah via swift-dev > wrote: > > Hi all, > > This is the first time I work on that deep of the compiler (in SR-3423 Enum > with tuple raw value not allowed) and I’m not sure where to start and what do > I need to do and what files this issue is related

Re: [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-10 Thread Brent Royal-Gordon via swift-dev
> Personally I like the flexibility provided by the associatedtype, but I also > recognize it won't be incredibly useful for enums — more so if we wanted to > provide e.g. UInt8.allValues, whose ideal implementation might be "return > 0...UInt8.max". So I could see allowing allValues to be any s

Re: [swift-dev] [swift-evolution] Re-pitch: Deriving collections of enum cases

2017-11-12 Thread Brent Royal-Gordon via swift-dev
> On Nov 10, 2017, at 11:01 PM, Xiaodi Wu wrote: > > Nit: if you want to call it `ValueEnumerable`, then this should be > `DefaultValueCollection`. I used `DefaultCaseCollection` because, although the protocol can work with any type to return its values, this type can only work with enums and

Re: [swift-dev] SR-3423 Starter questions

2017-11-13 Thread Brent Royal-Gordon via swift-dev
> On Nov 11, 2017, at 2:59 PM, Mohammed Ennabah via swift-dev > wrote: > > I dug into the codebase as stated in the steps you mentioned, and tried to > change one of the errors to see if it really change when I use Swift REPL, > but nothing changed. Is it possible that I change something and d

Re: [swift-dev] SR-3423 Starter questions

2017-11-13 Thread Brent Royal-Gordon via swift-dev
> On Nov 13, 2017, at 9:52 AM, Mohammed Ennabah wrote: > > I’m not sure what I’m missing when I build "utils/build-scrip”, but I keep > getting > "can't find source directory for cmark (tried > /Users/Mohammed/swift-source/cmark)” > > Just to know: I mkdir “swift-source” and then cloned the pr

Re: [swift-dev] [swift-evolution] Re-pitch: Deriving collections of enum cases

2017-11-13 Thread Brent Royal-Gordon via swift-dev
> On Nov 12, 2017, at 10:16 AM, Xiaodi Wu wrote: > > On Sun, Nov 12, 2017 at 4:54 AM, Brent Royal-Gordon > wrote: >> On Nov 10, 2017, at 11:01 PM, Xiaodi Wu > > wrote: >> >> Nit: if you want to call it `ValueEnumerable`, then this shoul

Re: [swift-dev] [swift-evolution] Re-pitch: Deriving collections of enum cases

2017-11-14 Thread Brent Royal-Gordon via swift-dev
> On Nov 13, 2017, at 9:21 PM, Xiaodi Wu wrote: > > ...I should add, if full conformance to `Collection` is still too much to > ask, enabling "for `case` in Foo.self" by magic would itself address the > entirety of the proposal's use case, adding no API surface area. No, Xiaodi. No, it would

Re: [swift-dev] [swift-evolution] Re-pitch: Deriving collections of enum cases

2017-11-14 Thread Brent Royal-Gordon via swift-dev
> On Nov 14, 2017, at 5:21 PM, Xiaodi Wu wrote: > > 1. It must be possible to easily access the count of values, and to access > any particular value using contiguous `Int` indices. This could be achieved > either by directly accessing elements in the list of values through an Int > subscript,

Re: [swift-dev] [Issue] Collection.distance() works not very well in some situations

2017-12-04 Thread Brent Royal-Gordon via swift-dev
> On Dec 2, 2017, at 12:28 PM, Cao, Jiannan via swift-dev > wrote: > > The question is that, whether the original Collection Protocol requires index > from lower to higher (startIndex < endIndex). `Collection` does require that `startIndex <= endIndex`, and in general, that `i < c.index(afte

Re: [swift-dev] [Proposal] RangeReplaceableCollection should inherits from MutableCollection

2017-12-04 Thread Brent Royal-Gordon via swift-dev
> On Dec 2, 2017, at 12:31 PM, Cao, Jiannan via swift-dev > wrote: > > I'd like to discuss the relation between RangeReplaceableCollection and > MutableCollection > > MutableCollection is a Collection type that can { set } any element with > subscript(position: Index). (and also { set } for s

Re: [swift-dev] [SE-0143] Dynamic casting for conditional conformances

2017-12-10 Thread Brent Royal-Gordon via swift-dev
> On Dec 5, 2017, at 2:28 PM, Douglas Gregor via swift-dev > wrote: > > To perform that mapping from a mangled type in a conditional requirement to > type metadata, we effectively need an operation to take a mangled type name > and turn it into a type metadata pointer. This is something we cou

Re: [swift-dev] [Question] Why StringProtocol not inherit RangeReplaceableCollection?

2017-12-11 Thread Brent Royal-Gordon via swift-dev
> On Dec 6, 2017, at 3:15 AM, Cao, Jiannan via swift-dev > wrote: > > Hi everyone, > > I have a question about StringProtocol. > Since String and Substring are adopted RangeReplaceableCollection, why > StringProtocol not inherit RangeReplaceableCollection? With the goal of teaching a man to f