Re: [swift-evolution] Generic Subscripts

2017-01-24 Thread Thorsten Seitz via swift-evolution
> Am 23.01.2017 um 18:26 schrieb Gwendal Roué : > >> Where generic subscripts are concerned, there are a couple of different >> things to express: >> - Generic parameter (I can understand various co-ordinates for the data) >> - Generic return type (I

Re: [swift-evolution] Generic Subscripts

2017-01-23 Thread Robert Widmann via swift-evolution
This can be made typesafe if the ObjectIdentifier of the archetype is stored with the key and checked on retrieval. ~Robert Widmann 2017/01/23 11:43、Thorsten Seitz via swift-evolution のメッセージ: > > >> Am 14.01.2017 um 14:50 schrieb Gwendal Roué via swift-evolution

Re: [swift-evolution] Generic Subscripts

2017-01-23 Thread Gwendal Roué via swift-evolution
> Where generic subscripts are concerned, there are a couple of different > things to express: > - Generic parameter (I can understand various co-ordinates for the data) > - Generic return type (I can construct your preferred representation of > the data) > - Generic

Re: [swift-evolution] Generic Subscripts

2017-01-23 Thread Thorsten Seitz via swift-evolution
> Am 14.01.2017 um 14:50 schrieb Gwendal Roué via swift-evolution > : > Where generic subscripts are concerned, there are a couple of different things to express: - Generic parameter (I can understand various co-ordinates for the data) - Generic

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread John McCall via swift-evolution
> On Jan 15, 2017, at 8:32 PM, Dave Abrahams wrote: > > > on Sun Jan 15 2017, John McCall wrote: > >>> On Jan 15, 2017, at 7:22 PM, Dave Abrahams wrote: >>> on Sun Jan 15 2017, John McCall wrote: >>> > On Jan 14, 2017, at 6:41 PM, Dave

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread Dave Abrahams via swift-evolution
on Sun Jan 15 2017, John McCall wrote: >> On Jan 15, 2017, at 7:22 PM, Dave Abrahams wrote: >> on Sun Jan 15 2017, John McCall wrote: >> On Jan 14, 2017, at 6:41 PM, Dave Abrahams via swift-evolution > wrote: on Fri Jan 13

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread John McCall via swift-evolution
> On Jan 15, 2017, at 7:22 PM, Dave Abrahams wrote: > on Sun Jan 15 2017, John McCall wrote: > >>> On Jan 14, 2017, at 6:41 PM, Dave Abrahams via swift-evolution >>> wrote: >>> on Fri Jan 13 2017, John McCall wrote:

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread Dave Abrahams via swift-evolution
on Sun Jan 15 2017, Jacob Bandes-Storch wrote: > On Sat, Jan 14, 2017 at 3:41 PM, Dave Abrahams via swift-evolution < > swift-evolution@swift.org> wrote: > >> >> on Fri Jan 13 2017, John McCall wrote: >> >> > I'm also not sure we'd ever want the element type to be

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread Dave Abrahams via swift-evolution
on Sun Jan 15 2017, John McCall wrote: >> On Jan 14, 2017, at 6:41 PM, Dave Abrahams via swift-evolution >> wrote: >> on Fri Jan 13 2017, John McCall wrote: >> >>> I'm also not sure we'd ever want the element type to be inferred from >>>

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread John McCall via swift-evolution
> On Jan 13, 2017, at 9:33 PM, Brent Royal-Gordon > wrote: >> On Jan 13, 2017, at 9:50 AM, John McCall via swift-evolution >> wrote: >> >> I'm also not sure we'd ever want the element type to be inferred from >> context like this. Generic

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread John McCall via swift-evolution
> On Jan 14, 2017, at 6:41 PM, Dave Abrahams via swift-evolution > wrote: > on Fri Jan 13 2017, John McCall wrote: > >> I'm also not sure we'd ever want the element type to be inferred from >> context like this. Generic subscripts as I see

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread Jacob Bandes-Storch via swift-evolution
On Sat, Jan 14, 2017 at 3:41 PM, Dave Abrahams via swift-evolution < swift-evolution@swift.org> wrote: > > on Fri Jan 13 2017, John McCall wrote: > > > I'm also not sure we'd ever want the element type to be inferred from > > context like this. Generic subscripts as I

Re: [swift-evolution] Generic Subscripts

2017-01-15 Thread Chris Eidhof via swift-evolution
I agree with Dave. To me, building in a limit so that the return type can't be inferred seems arbitrary. On Sun, Jan 15, 2017 at 12:41 AM, Dave Abrahams via swift-evolution < swift-evolution@swift.org> wrote: > > on Fri Jan 13 2017, John McCall wrote: > > > I'm also

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Dave Abrahams via swift-evolution
on Fri Jan 13 2017, John McCall wrote: > I'm also not sure we'd ever want the element type to be inferred from > context like this. Generic subscripts as I see it are about being > generic over *indexes*, not somehow about presenting a polymorphic > value. Actually

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Gwendal Roué via swift-evolution
> Le 14 janv. 2017 à 18:45, Anton Zhilin a écrit : > > I’m not sure, but I think that in this case the specific type of these values > is determined at runtime. > Then a safe approach would be separate string: String?, bool: Bool?, int: > Int? computed properties, as

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On Jan 14, 2017, at 12:17 PM, Shawn Erickson via swift-evolution > wrote: > > I have a throwing style data marshaling layer that uses throwing and return > type inference to make the code clean and validation automatic with the > optional

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Rien via swift-evolution
> On 14 Jan 2017, at 18:45, Anton Zhilin via swift-evolution > wrote: > > I’m not sure, but I think that in this case the specific type of these values > is determined at runtime. > Then a safe approach would be separate string: String?, bool: Bool?, int: > Int?

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Shawn Erickson via swift-evolution
I have a throwing style data marshaling layer that uses throwing and return type inference to make the code clean and validation automatic with the optional ability to return default values if error or missing value, etc. This is for validating data coming from external sources into our app.

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Anton Zhilin via swift-evolution
I’m not sure, but I think that in this case the specific type of these values is determined at runtime. Then a safe approach would be separate string: String?, bool: Bool?, int: Int? computed properties, as it’s done in JSON parsers. if let bookCount = row.value(named: "bookCount").int { ...

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Shawn Erickson via swift-evolution
I have very similar needs as well to allow for things to be generic on return type. On Sat, Jan 14, 2017 at 5:50 AM Gwendal Roué via swift-evolution < swift-evolution@swift.org> wrote: > Where generic subscripts are concerned, there are a couple of different > things to express: > - Generic

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Goffredo Marocchi via swift-evolution
Sent from my iPhone > On 14 Jan 2017, at 13:50, Gwendal Roué via swift-evolution > wrote: > Where generic subscripts are concerned, there are a couple of different things to express: - Generic parameter (I can understand various co-ordinates for the

Re: [swift-evolution] Generic Subscripts

2017-01-14 Thread Gwendal Roué via swift-evolution
>>> Where generic subscripts are concerned, there are a couple of different >>> things to express: >>> - Generic parameter (I can understand various co-ordinates for the data) >>> - Generic return type (I can construct your preferred representation of the >>> data) >>> - Generic setter type (I

Re: [swift-evolution] Generic Subscripts

2017-01-13 Thread Brent Royal-Gordon via swift-evolution
> On Jan 13, 2017, at 9:50 AM, John McCall via swift-evolution > wrote: > > I'm also not sure we'd ever want the element type to be inferred from context > like this. Generic subscripts as I see it are about being generic over > *indexes*, not somehow about

Re: [swift-evolution] Generic Subscripts

2017-01-13 Thread Ben Cohen via swift-evolution
> On Jan 12, 2017, at 1:37 PM, Slava Pestov via swift-evolution > wrote: > >> Before I submit it, could someone let me know if adding generics to >> subscripts would influence the ABI? ( still feel pretty clueless in that >> area). > > It won’t change the ABI of

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Slava Pestov via swift-evolution
> On Jan 12, 2017, at 7:05 PM, Karl Wagner wrote: > > >> On 12 Jan 2017, at 22:37, Slava Pestov via swift-evolution >> > wrote: >> >>> >>> On Jan 12, 2017, at 9:53 AM, Chris Eidhof via swift-evolution >>>

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Karl Wagner via swift-evolution
> On 12 Jan 2017, at 22:37, Slava Pestov via swift-evolution > wrote: > >> >> On Jan 12, 2017, at 9:53 AM, Chris Eidhof via swift-evolution >> > wrote: >> >> Ok, I've got a draft up as a gist: >>

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Douglas Gregor via swift-evolution
> On Jan 12, 2017, at 9:53 AM, Chris Eidhof wrote: > > Ok, I've got a draft up as a gist: > https://gist.github.com/chriseidhof/6c681677d44903045587bf75fb17eb25 > Please remember to fill in the title

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Slava Pestov via swift-evolution
> On Jan 12, 2017, at 9:53 AM, Chris Eidhof via swift-evolution > wrote: > > Ok, I've got a draft up as a gist: > https://gist.github.com/chriseidhof/6c681677d44903045587bf75fb17eb25 > > >

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Slava Pestov via swift-evolution
> On Jan 12, 2017, at 9:56 AM, Gwendal Roué via swift-evolution > wrote: > > Hello Chris, thanks for this draft! > > May I suggest that the introduction mentions genericity on return type as > well? > > subscript(_ index: Int) -> T > > (I have database rows

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Gwendal Roué via swift-evolution
Hello Chris, thanks for this draft! May I suggest that the introduction mentions genericity on return type as well? subscript(_ index: Int) -> T (I have database rows in mind.) Gwendal > Le 12 janv. 2017 à 18:53, Chris Eidhof via swift-evolution > a écrit : >

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Matthew Johnson via swift-evolution
Thanks for putting this together! I’m looking forward to seeing this make it into the language! > On Jan 12, 2017, at 11:53 AM, Chris Eidhof via swift-evolution > wrote: > > Ok, I've got a draft up as a gist: >

Re: [swift-evolution] Generic Subscripts

2017-01-12 Thread Chris Eidhof via swift-evolution
Ok, I've got a draft up as a gist: https://gist.github.com/chriseidhof/6c681677d44903045587bf75fb17eb25 Before I submit it, could someone let me know if adding generics to subscripts would influence the ABI? ( still feel pretty clueless in that area). Thanks! On Thu, Jan 12, 2017 at 8:57 AM,

Re: [swift-evolution] Generic Subscripts

2017-01-11 Thread Douglas Gregor via swift-evolution
Sent from my iPhone > On Jan 11, 2017, at 11:05 PM, Chris Eidhof via swift-evolution > wrote: > > Okay, > > I agree that throwing subscripts would be great to have. Likewise, > generic(and maybe even throwing) properties could be useful. However, I think > that

Re: [swift-evolution] Generic Subscripts

2017-01-11 Thread Chris Eidhof via swift-evolution
Okay, I agree that throwing subscripts would be great to have. Likewise, generic(and maybe even throwing) properties could be useful. However, I think that for this proposal, it makes more sense to focus on just generic subscripts, and mention throwing subscripts as "future improvements"? On

Re: [swift-evolution] Generic Subscripts

2017-01-11 Thread Slava Pestov via swift-evolution
> On Jan 11, 2017, at 10:53 AM, Matthew Johnson via swift-evolution > wrote: > >> >> On Jan 11, 2017, at 12:32 PM, Erica Sadun via swift-evolution >> > wrote: >> >> >>> On Jan 11, 2017, at 12:26 AM,

Re: [swift-evolution] Generic Subscripts

2017-01-11 Thread John McCall via swift-evolution
> On Jan 11, 2017, at 1:32 PM, Erica Sadun via swift-evolution > wrote: >> On Jan 11, 2017, at 12:26 AM, Chris Lattner via swift-evolution >> > wrote: >> >> On Jan 10, 2017, at 11:40 AM, Douglas Gregor via

Re: [swift-evolution] Generic Subscripts

2017-01-11 Thread Matthew Johnson via swift-evolution
> On Jan 11, 2017, at 12:32 PM, Erica Sadun via swift-evolution > wrote: > > >> On Jan 11, 2017, at 12:26 AM, Chris Lattner via swift-evolution >> > wrote: >> >> On Jan 10, 2017, at 11:40 AM, Douglas

Re: [swift-evolution] Generic Subscripts

2017-01-11 Thread Douglas Gregor via swift-evolution
> On Jan 11, 2017, at 10:32 AM, Erica Sadun wrote: > > >> On Jan 11, 2017, at 12:26 AM, Chris Lattner via swift-evolution >> > wrote: >> >> On Jan 10, 2017, at 11:40 AM, Douglas Gregor via swift-evolution >>

Re: [swift-evolution] Generic Subscripts

2017-01-11 Thread Erica Sadun via swift-evolution
> On Jan 11, 2017, at 12:26 AM, Chris Lattner via swift-evolution > wrote: > > On Jan 10, 2017, at 11:40 AM, Douglas Gregor via swift-evolution > > wrote: >>> On Jan 10, 2017, at 10:34 AM, Michael Ilseman

Re: [swift-evolution] Generic Subscripts

2017-01-10 Thread Douglas Gregor via swift-evolution
> On Jan 10, 2017, at 1:44 PM, Stephen Celis wrote: > >> On Jan 10, 2017, at 2:40 PM, Douglas Gregor via swift-evolution >> wrote: >> >> It’s a nontrivial new user-facing feature with new syntax in the language, >> so it’ll need a

Re: [swift-evolution] Generic Subscripts

2017-01-10 Thread Stephen Celis via swift-evolution
> On Jan 10, 2017, at 2:40 PM, Douglas Gregor via swift-evolution > wrote: > > It’s a nontrivial new user-facing feature with new syntax in the language, so > it’ll need a proposal. ‘twould be good for the proposal to link to the JIRA > ticket. > > - Doug I

Re: [swift-evolution] Generic Subscripts

2017-01-10 Thread Douglas Gregor via swift-evolution
> On Jan 10, 2017, at 10:34 AM, Michael Ilseman via swift-evolution > wrote: > > [Forgot to CC swift-evolution the first time] > > When this came up last, it was seen as more so a bug in the current > implementation, rather than an explicit choice. There's no need

Re: [swift-evolution] Generic Subscripts

2017-01-10 Thread Dave Abrahams via swift-evolution
on Tue Jan 10 2017, Chris Eidhof wrote: > Hi, > > Recently, I've bumped into the lack of generic subscripts a few times. > There are a bunch of useful things you could do with it. It's in the > generics manifesto as well: >

Re: [swift-evolution] Generic Subscripts

2017-01-10 Thread Michael Ilseman via swift-evolution
[Forgot to CC swift-evolution the first time] When this came up last, it was seen as more so a bug in the current implementation, rather than an explicit choice. There's no need for a proposal, just a JIRA: https://bugs.swift.org/browse/SR-115?jql=text%20~%20%22Generic%20subscript%22