[swift-evolution] Should we relax restriction on closing over outer scope in class declarations?

Xiaodi Wu xiaodi.wu at gmail.com
Sat Dec 24 03:27:19 CST 2016


Pedagogically, that is unworkable. A user who has learned about functions
would already know that a function can be defined inside another. If you
are teaching the concept of classes to that user, either you must first lie
and say that a class cannot be defined inside a function, or your student
will naturally discover that in fact you can--but then potentially
encounter behaviors that he or she cannot make sense of.

In any case, Robert's excellent analysis shows why this proposed feature
would simply break Swift, so the pedagogical objection is not even foremost
among issues.
On Sat, Dec 24, 2016 at 03:46 Guillaume DIDIER <
guillaume.didier at polytechnique.edu> wrote:

> If I understand correctly we are speaking of class definitions inside
> functions, so this doesn't affect classes defined at the global scope,
> which are what the beginner will first be told. Teaching them about
> defining classes in other places would then wait until they know more about
> closure, scopes and variable capture.
>
> I would suggest treating a class defined within a function body the same
> way a function defined within a function body would be.
>
> *Guillaume DIDIER (ASP)*
>
> *Section Escrime, 3ème Compagnie, Promotion X 2014*
>
>
>> *ÉCOLE POLYTECHNIQUE*
> 91128 PALAISEAU CEDEX
> M. +33 ( <+33%207%C2%A070%2043%2018%2040>0
> <+33%207%C2%A070%2043%2018%2040>)7 <+33%207%C2%A070%2043%2018%2040> 70 43
> 18 40 <+33%207%C2%A070%2043%2018%2040>
> guillaume.didier at polytechnique.edu
> <guillaume.didier at polytechnique.edu?subject=>
> www.polytechnique.edu
>>
> Le 23 déc. 2016 à 23:49, David Sweeris via swift-evolution <
> swift-evolution at swift.org> a écrit :
>
>
> On Dec 23, 2016, at 1:37 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>
> This has been an idea brought up in the distant past about other features.
> The core team has said very clearly that they do not want "dialects" of
> Swift.
>
>
> That puts the nail on it for me… if it’s already been rejected, I don’t
> want to rehash it.
>
> - Dave Sweeris
>
> _______________________________________________
>
>
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161224/833c26d5/attachment.html>


More information about the swift-evolution mailing list