[Idea] Deprecate the 'default' keyword.

Let's make this a topic of its own.

As mentioned recently in the '[Idea] Allowing most keywords after "."'
thread, the 'default' keyword is only used as a keyword in switch
statements, where it's synonymous with 'case _:'.
It's also the kind of word which appears commonly in enums.

So, why do we need to keep it as a keyword?

Disadvantages: there would be some breaking of code, but a migration tool
should have little difficulty replacing 'default:' with 'case _:' in all
cases.

Alternatives: replace 'default' with 'else'.

I kinda like Haskell’s “otherwise”, and it’s move obvious what it means than “default” from an English language point of view.

···

Let's make this a topic of its own.

As mentioned recently in the '[Idea] Allowing most keywords after "."' thread, the 'default' keyword is only used as a keyword in switch statements, where it's synonymous with 'case _:'.
It's also the kind of word which appears commonly in enums.

So, why do we need to keep it as a keyword?

Disadvantages: there would be some breaking of code, but a migration tool should have little difficulty replacing 'default:' with 'case _:' in all cases.

Alternatives: replace 'default' with 'else'._______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Ross O'Brien via swift-evolution <swift-evolution@...> writes:

Alternatives: replace 'default' with 'else'.

Unlike dropping the 'default' keyword (not commenting on that here), this
alternative idea adds very little value to warrant a change to the language.
'default' is clear and well-understood as is.

+1 (as always) for replacing "default" with "case _".

It's consistent with other uses of "_", teaches about the concept of "_", simplifies the language vocabulary, frees "default" to be used as a case and it also looks better. :)

R+

···

Sent from my iPhone

On 27 Feb 2016, at 15:31, Ross O'Brien via swift-evolution <swift-evolution@swift.org> wrote:

Let's make this a topic of its own.

As mentioned recently in the '[Idea] Allowing most keywords after "."' thread, the 'default' keyword is only used as a keyword in switch statements, where it's synonymous with 'case _:'.
It's also the kind of word which appears commonly in enums.

So, why do we need to keep it as a keyword?

Disadvantages: there would be some breaking of code, but a migration tool should have little difficulty replacing 'default:' with 'case _:' in all cases.

Alternatives: replace 'default' with 'else'.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Previous discussion:

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001393.html

···

On Sat, Feb 27, 2016 at 12:52 PM, Rudolf Adamkovic via swift-evolution < swift-evolution@swift.org> wrote:

+1 (as always) for replacing "default" with "case _".

It's consistent with other uses of "_", teaches about the concept of "_",
simplifies the language vocabulary, frees "default" to be used as a case
and it also looks better. :)

R+

Sent from my iPhone

> On 27 Feb 2016, at 15:31, Ross O'Brien via swift-evolution < > swift-evolution@swift.org> wrote:
>
> Let's make this a topic of its own.
>
> As mentioned recently in the '[Idea] Allowing most keywords after "."'
thread, the 'default' keyword is only used as a keyword in switch
statements, where it's synonymous with 'case _:'.
> It's also the kind of word which appears commonly in enums.
>
> So, why do we need to keep it as a keyword?
>
> Disadvantages: there would be some breaking of code, but a migration
tool should have little difficulty replacing 'default:' with 'case _:' in
all cases.
>
> Alternatives: replace 'default' with 'else'.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Not sure if you're directing the follow-up questions to me in
particular. But, speaking only as some guy on a mailing list, my two
cents are:

If the proposal to allow dot-keywords succeeds, then I cannot see any
particular reason why reprising this discussion will lead anywhere
other than re-rejection, since the key justification for re-evaluation
will be moot. If the proposal to allow dot-keywords fails, then as
Brent said we may have a changed calculus due to the switch to
lowercase for enum cases and option set values. Until that plays out
it seems to me this discussion may be premature.

FWIW, that a change in naming convention puts commonly used names in
conflict with reserved keywords is an insight that I don't remember
being raised in the original discussion about case conventions for
enum cases; I wonder if all involved in that discussion might have
changed their minds if this had been pointed out more prominently
earlier.

···

On Sat, Feb 27, 2016 at 3:32 PM, Ross O'Brien via swift-evolution <swift-evolution@swift.org> wrote:

Xiaodi, thanks for pointing that out. That's an unfortunate oversight.

Following on from Brent's comments, then... the proposal as is will probably
be rejected as before. Since I seem to have acted too quickly in submitting
it, do you think I should close it, or leave it so it can be edited? Would
editing it be as simple as pointing its link to the discussion on allowing
dot-keywords (since, apart from Tim's suggestion of Haskell's "otherwise",
everything argued in this thread is in that one), or is more substantial
editing required?

--Ross

On Sat, Feb 27, 2016 at 9:06 PM, Jacob Bandes-Storch via swift-evolution > <swift-evolution@swift.org> wrote:

Previous discussion:

[swift-evolution] Remove default case in switch-case

On Sat, Feb 27, 2016 at 12:52 PM, Rudolf Adamkovic via swift-evolution >> <swift-evolution@swift.org> wrote:

+1 (as always) for replacing "default" with "case _".

It's consistent with other uses of "_", teaches about the concept of "_",
simplifies the language vocabulary, frees "default" to be used as a case and
it also looks better. :)

R+

Sent from my iPhone

> On 27 Feb 2016, at 15:31, Ross O'Brien via swift-evolution >>> > <swift-evolution@swift.org> wrote:
>
> Let's make this a topic of its own.
>
> As mentioned recently in the '[Idea] Allowing most keywords after "."'
> thread, the 'default' keyword is only used as a keyword in switch
> statements, where it's synonymous with 'case _:'.
> It's also the kind of word which appears commonly in enums.
>
> So, why do we need to keep it as a keyword?
>
> Disadvantages: there would be some breaking of code, but a migration
> tool should have little difficulty replacing 'default:' with 'case _:' in
> all cases.
>
> Alternatives: replace 'default' with 'else'.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

This idea (replacing default) has already been proposed previously and
rejected. See:

···

On Sat, Feb 27, 2016 at 1:17 PM Daniel Duan via swift-evolution < swift-evolution@swift.org> wrote:

Ross O'Brien via swift-evolution <swift-evolution@...> writes:

> Alternatives: replace 'default' with 'else'.

Unlike dropping the 'default' keyword (not commenting on that here), this
alternative idea adds very little value to warrant a change to the
language.
'default' is clear and well-understood as is.

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Xiaodi, thanks for pointing that out. That's an unfortunate oversight.

Following on from Brent's comments, then... the proposal as is will
probably be rejected as before. Since I seem to have acted too quickly in
submitting it, do you think I should close it, or leave it so it can be
edited? Would editing it be as simple as pointing its link to the
discussion on allowing dot-keywords (since, apart from Tim's suggestion of
Haskell's "otherwise", everything argued in this thread is in that one), or
is more substantial editing required?

--Ross

···

On Sat, Feb 27, 2016 at 9:06 PM, Jacob Bandes-Storch via swift-evolution < swift-evolution@swift.org> wrote:

Previous discussion:

[swift-evolution] Remove default case in switch-case

On Sat, Feb 27, 2016 at 12:52 PM, Rudolf Adamkovic via swift-evolution < > swift-evolution@swift.org> wrote:

+1 (as always) for replacing "default" with "case _".

It's consistent with other uses of "_", teaches about the concept of "_",
simplifies the language vocabulary, frees "default" to be used as a case
and it also looks better. :)

R+

Sent from my iPhone

> On 27 Feb 2016, at 15:31, Ross O'Brien via swift-evolution < >> swift-evolution@swift.org> wrote:
>
> Let's make this a topic of its own.
>
> As mentioned recently in the '[Idea] Allowing most keywords after "."'
thread, the 'default' keyword is only used as a keyword in switch
statements, where it's synonymous with 'case _:'.
> It's also the kind of word which appears commonly in enums.
>
> So, why do we need to keep it as a keyword?
>
> Disadvantages: there would be some breaking of code, but a migration
tool should have little difficulty replacing 'default:' with 'case _:' in
all cases.
>
> Alternatives: replace 'default' with 'else'.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

This idea (replacing default) has already been proposed previously and rejected. See: https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md

It has been proposed before, but the switch to lowercase for enum cases and option set values may change the calculus.

(Which is why I *don't* think this should have been spun off into its own thread—you've detached the proposal from its justification.)

···

--
Brent Royal-Gordon
Architechies