[swift-users] Using Swift for interpreted shell scripts?

2015-12-15 Thread @lbutlr via swift-users
Are there any resources on using swift for shell scripting?

I’m interested in trying my hand at Swift by converting existing bash scripts 
into swift since bash is mostly what I am writing currently, so I figure this 
will at least get me started with syntax and such.

ZZ

-- 
The Steve is seen, rightly or wrongly, as the visionary, the leader,
the savant. Bill is the Boswell to The Steve's Johnson, but lacking
Boswell's wit, charm, and dynamic personality.

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


Re: [swift-users] Using Swift for interpreted shell scripts?

2015-12-15 Thread Erica Sadun via swift-users
I've given up on it. I find it far easier to just write a command-line app with 
Xcode's source support -- E

> On Dec 15, 2015, at 12:45 PM, @lbutlr via swift-users  
> wrote:
> 
> Are there any resources on using swift for shell scripting?
> 
> I’m interested in trying my hand at Swift by converting existing bash scripts 
> into swift since bash is mostly what I am writing currently, so I figure this 
> will at least get me started with syntax and such.
> 
> ZZ

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


[swift-users] For loop question?

2015-12-15 Thread cooper liu via swift-users
Hi,If the c style for loop was removed,how to implement the following code 
beautifully:For(var i=0; i < 10; i+=2)Since the range operator ... doesn't 
support step other than 1, and it doesn't support end value < start value.
Thanks!

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


Re: [swift-users] memory requirements for building swift on linux?

2015-12-15 Thread Luca Finzi Contini via swift-users
Hi,
I have tried to build the swift ecosystem on an Ubuntu 15.10 machine loaded
with 16GB of RAM and 16GB of swap space.
What happens is that if you run the "utils/build-script -t" command as
suggested, this will use all processors available to speedup the build
BUT
it will also try to perform parallel links of tools when finished
compiling.
This is when memory is filled up totally and disks start to grind.
I tried running the whole thing with just one single job, using:

utils/build-script -j 1 -t

and it took more time to finish but it finished :)

I think there could be room for some enhancements in the way that the build
script uses processors : either you know how much RAM isneeded to build the
whole thing, or just get down to one single job for the purpose of linking.



Message: 7
> Date: Mon, 14 Dec 2015 09:03:36 -0500
> From: Kevin Lundberg 
> To: swift-users@swift.org
> Subject: [swift-users] memory requirements for building swift on
> linux?
> Message-ID: <566ecc38.9030...@klundberg.com>
> Content-Type: text/plain; charset=utf-8
>
> Hi All,
>
> I've set up a linux VM (ubuntu 15.10) in virtualbox on my windows PC to
> build and test swift on linux, but I've been unable to successfully
> build it to completion. I have all the repos including the corelibs
> cloned locally, and have followed all the steps as far as I know for
> installing dependencies. Every time I build, it fails somewhere during
> linking, the last time failing when  linking "CXX shared library
> lib/libLTO.so".
>
> I don't have the full error, but I'm curious if there's some RAM
> requirement for building swift. My VM had 2GB, and I just bumped it up
> to 4GB to try again. Has anyone else run into this, and is there a
> recommended minimum needed to successfully build swift with? Could
> something else be the cause here instead of RAM if 2GB is in fact enough?
>
> Thanks!
>
> -Kevin
>
>
> --
>
> Message: 8
> Date: Mon, 14 Dec 2015 14:30:22 +
> From: Tobias Scholze 
> To: Kevin Lundberg , swift-users@swift.org
> Subject: Re: [swift-users] memory requirements for building swift on
> linux?
> Message-ID:
>  satpmp-donymnn...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
> to build Swift from the sources I used a 16 GB bare metal machine and it
> was not enough.
> So I think, you need a lot of memory ( > 16 GB) to have fun while building
> it.
>
> - Toby
>
> Kevin Lundberg via swift-users  schrieb am Mo., 14.
> Dez. 2015 um 15:03 Uhr:
>
> > Hi All,
> >
> > I've set up a linux VM (ubuntu 15.10) in virtualbox on my windows PC to
> > build and test swift on linux, but I've been unable to successfully
> > build it to completion. I have all the repos including the corelibs
> > cloned locally, and have followed all the steps as far as I know for
> > installing dependencies. Every time I build, it fails somewhere during
> > linking, the last time failing when  linking "CXX shared library
> > lib/libLTO.so".
> >
> > I don't have the full error, but I'm curious if there's some RAM
> > requirement for building swift. My VM had 2GB, and I just bumped it up
> > to 4GB to try again. Has anyone else run into this, and is there a
> > recommended minimum needed to successfully build swift with? Could
> > something else be the cause here instead of RAM if 2GB is in fact enough?
> >
> > Thanks!
> >
> > -Kevin
> > ___
> > swift-users mailing list
> > swift-users@swift.org
> > https://lists.swift.org/mailman/listinfo/swift-users
> >
> -- next part --
> An HTML attachment was scrubbed...
> URL: <
> https://lists.swift.org/pipermail/swift-users/attachments/20151214/5ef837e0/attachment-0001.html
> >
>
> --
>
> Message: 9
> Date: Mon, 14 Dec 2015 09:55:19 -0500
> From: Kevin Lundberg 
> To: Tobias Scholze , swift-users@swift.org
> Subject: Re: [swift-users] memory requirements for building swift on
> linux?
> Message-ID: <566ed857.90...@klundberg.com>
> Content-Type: text/plain; charset="utf-8"
>
> I was able to build it on my 8GB macbook successfully, but there may be
> platform differences there that caused that.
>
> It seems that 4GB isn't enough either, fails when linking clang-3.8.
> I'll have to figure something else out for linux for me. Thanks!
>
> On 12/14/2015 9:30 AM, Tobias Scholze wrote:
> > Hi,
> > to build Swift from the sources I used a 16 GB bare metal machine and
> > it was not enough.
> > So I think, you need a lot of memory ( > 16 GB) to have fun while
> > building it.
> >
> > - Toby
> >
> > Kevin Lundberg via swift-users  > > schrieb am Mo., 14. Dez. 2015 um
> > 15:03 Uhr:
> >
> > Hi All,
> >
> > I've set up a linux VM 

Re: [swift-users] Using Swift for interpreted shell scripts?

2015-12-15 Thread Jens Alfke via swift-users
Swift doesn’t seem like a good fit for the kinds of tasks people write 
shell-scripts for. It’s a system/app programming language, like C/C++. 
Scripting languages have extremely dynamic typing, super-high-level APIs, and 
no separate compile/link stage.

There’s no reason you couldn’t convert some shellscripts as an exercise to 
learn Swift, but I don’t think you’ll find many resources out there.

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


Re: [swift-users] Swift BMI

2015-12-15 Thread Eimantas Vaiciunas via swift-users
I exchanged a class to an enum since the BMI values are a finite set. This
eliminates a need for valid value check since the switch that is used to
initialise the enum value is exhaustive.

http://swiftstub.com/242291010/

On Tue, Dec 15, 2015 at 3:30 PM, Erica Sadun via swift-users <
swift-users@swift.org> wrote:

> Leaving aside typos, any discussion about the merits of BMI, and the
> intemperate language in the code, you do a few things that could be
> improved upon language-wise. Of these, the most egregious is the final
> "break the machine" else statement that can never be reached.
>
> The following example does several things:
> http://swiftstub.com/358512527
>
> * Adds a precondition to ensure that clients have passed valid arguments
> * Uses an enumeration (with a default value) instead of overloading a
> class function with nearly identical code
> * Introduces a multiplier to address the kg/lb difference
> * Establishes an upper case name for the class
> * Uses a switch statement instead of cascaded ifs
> * Returns a String instead of running procedurally
>
> -- E
>
>
> On Dec 14, 2015, at 8:20 PM, Gage Morgan via swift-users <
> swift-users@swift.org> wrote:
>
> For most languages I try out, my own version of "Hello World!" is a BMI
> calculator. Swift has passed, I encourage you to try it out.
>
> There are two methods called towards the end of file:
> 1) bmi.pounds(weight, height) - Replace numbers inside with your own if
> you want to test out in US Customary units.
>
> 2) bmi.kilograms(weight, height) - Replace numbers inside with your own if
> you want to test out in Metric units used everywhere outside the US.
>
> You already get the gist, the bits can be found here:
> https://gist.github.com/anonymous/9284017644567c29c7f8
>
> If there's a bug please let me know, but it works in IBM's Sandbox.
> (Yes, ALL code was written by me without help. Very close to C, just a bit
> laid back.)
> --MGage--
>
> ___
> 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 BMI

2015-12-15 Thread Erica Sadun via swift-users
And, of course, this is a perfect opportunity to use Swift tuple returns and 
eliminate the side-effect of printing the numeric value:

http://swiftstub.com/176972405

-- E, whose kids have a snow day this morning in case you can't tell


> On Dec 15, 2015, at 7:20 AM, Erica Sadun  wrote:
> 
> In fact, there's no really good reason to use any construct, whether struct, 
> class, or enum, for this at all since the BMI isn't a "thing" per se.  A 
> global function might be a better fit.
> 
> http://swiftstub.com/443052056 
> 
> -- E
> 
>> On Dec 15, 2015, at 7:10 AM, Eimantas Vaiciunas via swift-users 
>> > wrote:
>> 
>> I exchanged a class to an enum since the BMI values are a finite set. This 
>> eliminates a need for valid value check since the switch that is used to 
>> initialise the enum value is exhaustive.
>> 
>> http://swiftstub.com/242291010/ 
>> 
>> On Tue, Dec 15, 2015 at 3:30 PM, Erica Sadun via swift-users 
>> > wrote:
>> Leaving aside typos, any discussion about the merits of BMI, and the 
>> intemperate language in the code, you do a few things that could be improved 
>> upon language-wise. Of these, the most egregious is the final "break the 
>> machine" else statement that can never be reached.
>> 
>> The following example does several things:
>> http://swiftstub.com/358512527 
>> 
>> * Adds a precondition to ensure that clients have passed valid arguments
>> * Uses an enumeration (with a default value) instead of overloading a class 
>> function with nearly identical code
>> * Introduces a multiplier to address the kg/lb difference
>> * Establishes an upper case name for the class
>> * Uses a switch statement instead of cascaded ifs 
>> * Returns a String instead of running procedurally
>> 
>> -- E
>> 
>> 
>>> On Dec 14, 2015, at 8:20 PM, Gage Morgan via swift-users 
>>> > wrote:
>>> 
>>> For most languages I try out, my own version of "Hello World!" is a BMI 
>>> calculator. Swift has passed, I encourage you to try it out. 
>>> 
>>> There are two methods called towards the end of file:
>>> 1) bmi.pounds(weight, height) - Replace numbers inside with your own if you 
>>> want to test out in US Customary units. 
>>> 
>>> 2) bmi.kilograms(weight, height) - Replace numbers inside with your own if 
>>> you want to test out in Metric units used everywhere outside the US. 
>>> 
>>> You already get the gist, the bits can be found here:
>>> https://gist.github.com/anonymous/9284017644567c29c7f8 
>>> 
>>> 
>>> If there's a bug please let me know, but it works in IBM's Sandbox. 
>>> (Yes, ALL code was written by me without help. Very close to C, just a bit 
>>> laid back.)
>>> --MGage--
>>> 
>>>  ___
>>> 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 
>> 

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


Re: [swift-users] Swift BMI

2015-12-15 Thread Erica Sadun via swift-users
In fact, there's no really good reason to use any construct, whether struct, 
class, or enum, for this at all since the BMI isn't a "thing" per se.  A global 
function might be a better fit.

http://swiftstub.com/443052056

-- E

> On Dec 15, 2015, at 7:10 AM, Eimantas Vaiciunas via swift-users 
>  wrote:
> 
> I exchanged a class to an enum since the BMI values are a finite set. This 
> eliminates a need for valid value check since the switch that is used to 
> initialise the enum value is exhaustive.
> 
> http://swiftstub.com/242291010/ 
> 
> On Tue, Dec 15, 2015 at 3:30 PM, Erica Sadun via swift-users 
> > wrote:
> Leaving aside typos, any discussion about the merits of BMI, and the 
> intemperate language in the code, you do a few things that could be improved 
> upon language-wise. Of these, the most egregious is the final "break the 
> machine" else statement that can never be reached.
> 
> The following example does several things:
> http://swiftstub.com/358512527 
> 
> * Adds a precondition to ensure that clients have passed valid arguments
> * Uses an enumeration (with a default value) instead of overloading a class 
> function with nearly identical code
> * Introduces a multiplier to address the kg/lb difference
> * Establishes an upper case name for the class
> * Uses a switch statement instead of cascaded ifs 
> * Returns a String instead of running procedurally
> 
> -- E
> 
> 
>> On Dec 14, 2015, at 8:20 PM, Gage Morgan via swift-users 
>> > wrote:
>> 
>> For most languages I try out, my own version of "Hello World!" is a BMI 
>> calculator. Swift has passed, I encourage you to try it out. 
>> 
>> There are two methods called towards the end of file:
>> 1) bmi.pounds(weight, height) - Replace numbers inside with your own if you 
>> want to test out in US Customary units. 
>> 
>> 2) bmi.kilograms(weight, height) - Replace numbers inside with your own if 
>> you want to test out in Metric units used everywhere outside the US. 
>> 
>> You already get the gist, the bits can be found here:
>> https://gist.github.com/anonymous/9284017644567c29c7f8 
>> 
>> 
>> If there's a bug please let me know, but it works in IBM's Sandbox. 
>> (Yes, ALL code was written by me without help. Very close to C, just a bit 
>> laid back.)
>> --MGage--
>> 
>>  ___
>> 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 
> 
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users