[swift-users] Inconsistent behaviour of forward declarations

肇鑫 owenzx at gmail.com
Sat Jan 9 20:58:32 CST 2016


I think the codes should not run in a playground file. But they should run
in a swift file. Both assuming they are outside a class/struct/enum.

Because in playground, codes run from top to bottom; in swift file, all
global variables and functions are known by the compiler before the app
runs.

zhaoxin

On Sun, Jan 10, 2016 at 7:08 AM, Victor Guerra via swift-users <
swift-users at swift.org> wrote:

>
>
> On Sat, Jan 9, 2016 at 11:56 PM Dan Cutting <dan at cutting.io> wrote:
>
>> Thanks Victor.
>>
>> Actually, that snippet works in the v2.1.1 REPL as well, so I think the
>> REPL environment works differently.
>>
>>
> Both v2.1.1 and v2.2-dev fail when running that code as a script.
>>
>>
> You are right Dan. I did give it a try previously from the REPL. And yes,
> fails if scripted.
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>


-- 

Owen Zhao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160110/75b9229d/attachment.html>


More information about the swift-users mailing list