[swift-evolution] Revisiting SE-0041 Names

David Sweeris davesweeris at mac.com
Wed Jun 22 19:15:05 CDT 2016


That's a really interesting idea. Is "Syntax" a placeholder, or is that the intended name? Also, why an enum? Especially one without any cases...

Was all this already discussed in a thread that I missed (or have otherwise forgotten about)?

- Dave Sweeris

Sent from my iPhone

> On Jun 22, 2016, at 15:54, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> 
>> On Wed, Jun 22, 2016 at 12:57 PM, David Sweeris <davesweeris at mac.com> wrote:
>> 
>>> On Jun 22, 2016, at 1:55 PM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> On Wed, Jun 22, 2016 at 11:04 AM, Erica Sadun via swift-evolution
>>> <swift-evolution at swift.org> wrote:
>>> 
>>> Hi Erica,
>>> 
>>> I would like to re-state the feedback from Dave Abrahams, Max Moiseev
>>> and me from the last time this was discussed.  Unfortunately I can't
>>> find the exact email, so I can't provide a link.
>>> 
>>> - The "literal" protocols are not about conversion, they are about
>>> adopting a certain syntax provided by the language.  "Convertible" in
>>> the name is a red herring: a type can't be convertible from an integer
>>> literal because there is no "IntegerLiteral" entity in the type
>>> system.  The literal *becomes* typed as the corresponding literal type
>>> (e.g., Int or String), and as far as the user at the call site is
>>> concerned, there is no visible conversion (even if one is happening
>>> behind the scenes).
>>> 
>>> Our suggestion was to focus on the "adopting the syntax" part.  We
>>> suggested moving the "literal convertible" protocols into a
>>> pseudo-namespace "Syntax".  It could be implemented like this:
>>> 
>>> protocol _IntegerLiteralSyntax {}
>>> enum Syntax {
>>> typealias IntegerLiteral = _IntegerLiteralSyntax
>>> }
>>> 
>>> And used like this:
>>> 
>>> struct Int : Syntax.IntegerLiteral {}
>>> 
>>> - For protocols that are representing conversions between types that
>>> actually exist in the library, there is not enough precedent yet to
>>> make a general conclusion and standardize a pattern.
>> 
>> I’m not sure I understand… In this example, has “IntegerLiteralConvertible” been renamed to “_IntegerLiteralSyntax”?
> 
> That's right.  But we want users to refer to the protocol as
> 'Syntax.IntegerLiteral'.  If/once we get either submodules or
> protocols nested in enums, we can move the actual definition to be
> nested.
> 
> Dmitri
> 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list