Re: [swift-users] passing command line arguments to `swift test`

2017-05-19 Thread Kelvin Ma via swift-users
i want to be able to run a single test case at a time instead of my whole test 
suite and i’m currently invoking the test binary directly after doing `swift 
test`

On May 19, 2017, at 4:56 PM, Brent Royal-Gordon  wrote:

>> On May 18, 2017, at 8:16 AM, Kelvin Ma via swift-users 
>>  wrote:
>> 
>> Is there a way I can pass command line arguments along to the testing 
>> program with `swift test` so that they are visible in 
>> `CommandLine.arguments`?
> 
> No. If there were one, you would not be able to reliably invoke the tests 
> automatically.
> 
> What are you trying to do? Test code that uses `CommandLine.arguments`?
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Swift 4.0 forEach problem

2017-05-19 Thread Slava Pestov via swift-users
Thanks, do you mind filing a bug at bugs.swift.org ?

Slava

> On May 19, 2017, at 4:18 PM, Edward Connell via swift-users 
>  wrote:
> 
> In swift 3.1.1 I was able to have the function below, which "gets" an 
> optional member collection of objects and calls their setModel member 
> function. Simple and clean using the forEach method.
> 
> public func setModel(model: Model) {
> get()?.forEach { $0.setModel(model: model) }
> }
> 
> However it now fails with Swift 4.0 saying: Extraneous argument label 
> 'model:' in call
> 
> ---
> If I rewrite the function as follows, then it compiles with no errors.
> 
> public func setModel(model: Model) {
> if let items = get() {
> for item in items {
> item.setModel(model: model)
> }
> }
> }
> 
> Something is broken...
> 
> Any ideas what is wrong?
> 
> Thanks, Ed
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Swift 4.0 forEach problem

2017-05-19 Thread Edward Connell via swift-users
In swift 3.1.1 I was able to have the function below, which "gets" an
optional member collection of objects and calls their setModel member
function. Simple and clean using the forEach method.

public func setModel(model: Model) {

get()?.forEach { $0.setModel(*model*: model) }
}

However it now fails with Swift 4.0 saying: *Extraneous argument label
'model:' in call*

---
If I rewrite the function as follows, then it compiles with no errors.

public func setModel(model: Model) {
if let items = get() {
for item in items {
item.setModel(model: model)
}
}
}


Something is broken...

Any ideas what is wrong?

Thanks, Ed
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] swift 4.0 "swift-version 4" errors with "type(of:"

2017-05-19 Thread David Hart via swift-users
That's worrisome. type is such a common identifier that I worry its going to 
break a lot of code, create some confusion and force the un-esthetic qualifying.

> On 19 May 2017, at 21:38, Slava Pestov via swift-users 
>  wrote:
> 
> Do you have a member named ‘type’ in the current scope?
> 
> We changed the behavior of type(of:) so that it behaves like a normal 
> declaration in the Swift module instead of a special keyword. Unfortunately 
> this means if you have a ‘type’ already visible in scope, you have to fully 
> qualify Swift.type(of:).
> 
> Slava
> 
>> On May 19, 2017, at 11:18 AM, Edward Connell via swift-users 
>>  wrote:
>> 
>> When running the compiler using the "-swift-version 4" flag, the compiler 
>> complains about creating a dynamic type. Errors are flagged from within 
>> concrete base classes and also within protocol extensions.
>> 
>> error: cannot invoke 'type' with an argument list of type '(of: Self)'
>> let newObject = type(of: self).init()
>> 
>> Has this changed?? Are we supposed to create dynamic types a different way 
>> now?
>> 
>> Thanks, Ed
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] swift 4.0 "swift-version 4" errors with "type(of:"

2017-05-19 Thread Edward Connell via swift-users
Yes I did, that fixed the problem. Thank you

On Fri, May 19, 2017 at 12:38 PM, Slava Pestov  wrote:

> Do you have a member named ‘type’ in the current scope?
>
> We changed the behavior of type(of:) so that it behaves like a normal
> declaration in the Swift module instead of a special keyword. Unfortunately
> this means if you have a ‘type’ already visible in scope, you have to fully
> qualify Swift.type(of:).
>
> Slava
>
> On May 19, 2017, at 11:18 AM, Edward Connell via swift-users <
> swift-users@swift.org> wrote:
>
> When running the compiler using the "-swift-version 4" flag, the compiler
> complains about creating a dynamic type. Errors are flagged from within
> concrete base classes and also within protocol extensions.
>
> *error: cannot invoke 'type' with an argument list of type '(of: Self)'*
> *let newObject = type(of: self).init()*
>
> Has this changed?? Are we supposed to create dynamic types a different way
> now?
>
> Thanks, Ed
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] swift 4.0 "swift-version 4" errors with "type(of:"

2017-05-19 Thread Slava Pestov via swift-users
Do you have a member named ‘type’ in the current scope?

We changed the behavior of type(of:) so that it behaves like a normal 
declaration in the Swift module instead of a special keyword. Unfortunately 
this means if you have a ‘type’ already visible in scope, you have to fully 
qualify Swift.type(of:).

Slava

> On May 19, 2017, at 11:18 AM, Edward Connell via swift-users 
>  wrote:
> 
> When running the compiler using the "-swift-version 4" flag, the compiler 
> complains about creating a dynamic type. Errors are flagged from within 
> concrete base classes and also within protocol extensions.
> 
> error: cannot invoke 'type' with an argument list of type '(of: Self)'
> let newObject = type(of: self).init()
> 
> Has this changed?? Are we supposed to create dynamic types a different way 
> now?
> 
> Thanks, Ed
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] swift 4.0 "swift-version 4" errors with "type(of:"

2017-05-19 Thread Edward Connell via swift-users
When running the compiler using the "-swift-version 4" flag, the compiler
complains about creating a dynamic type. Errors are flagged from within
concrete base classes and also within protocol extensions.

*error: cannot invoke 'type' with an argument list of type '(of: Self)'*
*let newObject = type(of: self).init()*

Has this changed?? Are we supposed to create dynamic types a different way
now?

Thanks, Ed
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] swift 4.0 complains/warns about swapping array elements

2017-05-19 Thread Edward Connell via swift-users
Great! Yes, changing the diagnostic message will save people from having to
ask this question.

Thanks, Ed

On Fri, May 19, 2017 at 10:30 AM, Devin Coughlin 
wrote:

> Hi Ed,
>
> On May 19, 2017, at 10:10 AM, Edward Connell via swift-users <
> swift-users@swift.org> wrote:
>
> I just switched to the 5/17 swift 4.0 tool chain on Linux, and I am
> getting the following complaint when using swap on array elements. Is this
> warning legitimate because of a copy on write issue? If so, is there some
> new swap function for array elements? I realize I can turn 1 line into 3
> and do the swapping myself, it's just verbose.
>
> *warning: simultaneous accesses to var 'dims', but modification requires
> exclusive access; consider copying to a local variable*
> *swap(&dims[lastIndex],
> &dims[lastIndex-1])*
>
>
> You can use the new swapAt() method:
>
>dims.swapAt(lastIndex, lastIndex-1)
>
> I recently added a Fix-It for this — but we really should also say
> "consider using ‘swapAt()’” in the diagnostic text as well in this case
> rather then mentioning copying to a local.
>
> Devin
>
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] swift 4.0 complains/warns about swapping array elements

2017-05-19 Thread Devin Coughlin via swift-users
Hi Ed,

> On May 19, 2017, at 10:10 AM, Edward Connell via swift-users 
>  wrote:
> 
> I just switched to the 5/17 swift 4.0 tool chain on Linux, and I am getting 
> the following complaint when using swap on array elements. Is this warning 
> legitimate because of a copy on write issue? If so, is there some new swap 
> function for array elements? I realize I can turn 1 line into 3 and do the 
> swapping myself, it's just verbose.
> 
> warning: simultaneous accesses to var 'dims', but modification requires 
> exclusive access; consider copying to a local variable
> swap(&dims[lastIndex], &dims[lastIndex-1])

You can use the new swapAt() method:

   dims.swapAt(lastIndex, lastIndex-1)

I recently added a Fix-It for this — but we really should also say "consider 
using ‘swapAt()’” in the diagnostic text as well in this case rather then 
mentioning copying to a local.

Devin


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] swift 4.0 complains/warns about swapping array elements

2017-05-19 Thread David Sweeris via swift-users

> On May 19, 2017, at 10:10, Edward Connell via swift-users 
>  wrote:
> 
> I just switched to the 5/17 swift 4.0 tool chain on Linux, and I am getting 
> the following complaint when using swap on array elements. Is this warning 
> legitimate because of a copy on write issue? If so, is there some new swap 
> function for array elements? I realize I can turn 1 line into 3 and do the 
> swapping myself, it's just verbose.
> 
> warning: simultaneous accesses to var 'dims', but modification requires 
> exclusive access; consider copying to a local variable
> swap(&dims[lastIndex], &dims[lastIndex-1])

Looks like it got changed to "swapAt": 
https://github.com/apple/swift-evolution/blob/master/proposals/0173-swap-indices.md

Hope that helps,
- Dave Sweeris ___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] swift 4.0 complains/warns about swapping array elements

2017-05-19 Thread Edward Connell via swift-users
I just switched to the 5/17 swift 4.0 tool chain on Linux, and I am getting
the following complaint when using swap on array elements. Is this warning
legitimate because of a copy on write issue? If so, is there some new swap
function for array elements? I realize I can turn 1 line into 3 and do the
swapping myself, it's just verbose.

*warning: simultaneous accesses to var 'dims', but modification requires
exclusive access; consider copying to a local variable*
*swap(&dims[lastIndex], &dims[lastIndex-1])*

Thanks, Ed
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Generating html code, best practise?

2017-05-19 Thread Rien via swift-users
I want to generate some HTML code with Swift. Of course there are many way to 
do this, but I am not looking to do an "in-dept all options open” approach.
Just some ‘get the html out quickly” type of thing.

So I wonder, how do _you_ do this?

Simply using Strings is one option, but cumbersome and without any 
‘html-type-safety’
Using some general purpose function (e.g. func tagged(tag: String, content: 
String) -> String) helps a little, but not very much.
Enums are another possibility.
Or var’s in a struct/class that wrap the html element etc.

Many possibilities.

Any suggestion is welcome, suggestions as wel as experiences.
Of course if there is a solution out there, I’d like to know as well. (I didn’t 
find any though)


Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server for websites build in Swift






___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users