Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-21 Thread ToddAndMargo
> On Wed, Mar 22, 2017 at 12:59 AM, ToddAndMargo wrote: >> Hi All, >> >> Yes, I know, Perl is "lexiconical". >> >> $ perl6 -e 'my $x="abc"; $x=1E23; print "$x\n";' >> 1e+23 >> >> $ perl6 -e 'my Str $x="abc"; $x=1E23; print "$x\n";' >> Type check failed in assignment to $x; expected Str >> but go

Re: File::Copy ??

2017-03-21 Thread ToddAndMargo
> On Wed, Mar 22, 2017 at 12:24 AM, ToddAndMargo wrote: >> Hi All, >> >> Do we have anything like >> >> http://perldoc.perl.org/File/Copy.html >> >> under another name? >> >> Nothing showed up in >>https://modules.perl6.org/#q=file%3A%3A >> >> >> Many thanks, >> -T On 03/21/2017 10:59 PM, B

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-21 Thread Brad Gilbert
The default type constraint is Mu, with a default of Any (everything is of type Mu, and most are of type Any) You shouldn't be able to change the type constraint of a scalar container (used for rw variables) Changing the type of a value, of course makes no sense. (a Str is always a Str, even when

Re: File::Copy ??

2017-03-21 Thread Brad Gilbert
For basic copy and move, the built-in subs should work https://docs.perl6.org/routine/copy https://docs.perl6.org/routine/move On Wed, Mar 22, 2017 at 12:24 AM, ToddAndMargo wrote: > Hi All, > > Do we have anything like > > http://perldoc.perl.org/File/Copy.html > > under another name? > > Nothi

Am I suppose to be able to change a variable's type on the fly?

2017-03-21 Thread ToddAndMargo
Hi All, Yes, I know, Perl is "lexiconical". $ perl6 -e 'my $x="abc"; $x=1E23; print "$x\n";' 1e+23 $ perl6 -e 'my Str $x="abc"; $x=1E23; print "$x\n";' Type check failed in assignment to $x; expected Str but got Num (1e+23) in block at -e line 1 So, unless I specifically declare a variable as

File::Copy ??

2017-03-21 Thread ToddAndMargo
Hi All, Do we have anything like http://perldoc.perl.org/File/Copy.html under another name? Nothing showed up in https://modules.perl6.org/#q=file%3A%3A Many thanks, -T -- Yesterday it worked. Today it is not working. Windows is like that. ~~

[perl #131008] lcm should not work with Nums, and maybe gcd too (2.5 lcm 5)

2017-03-21 Thread Zoffix Znet via RT
Thank you for the report. However, there's no bug here and I'm going to reject this ticket. > Another option is to make it return 5 (kinda DWIM) No, it's not another option because that doesn't make any sense mathematically. The math operations lcm[^1] and gcd[^2] ops perform apply to integer

Re: maintainability and "or"

2017-03-21 Thread ToddAndMargo
Thank you all for the wonderful training and feedback!

Re: maintainability and "or"

2017-03-21 Thread ToddAndMargo
On 03/21/2017 11:25 AM, Brandon Allbery wrote: people comparing perl 5 speed to perl 6 should take note: perl 5 used to be slow too If you wanted "speed", code in C or assembly. I am after rapid development. Perl 6 is perfect. -- ~~ Computers are like air

Re: maintainability and "or"

2017-03-21 Thread ToddAndMargo
On 03/21/2017 04:50 AM, Elizabeth Mattijsen wrote: $PathAndName.IO.open(:w).close unless $PathAndName.IO.f; Hi Liz, Now that is elegant! Thank you! -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~~

Re: Question for the developers on splice

2017-03-21 Thread ToddAndMargo
On 03/21/2017 08:10 AM, Parrot Raiser wrote: "Premature optimisation is the root of many evils", or words to that effect. (I forget who said it, but I think it was someone credible.) Write your code as clearly and simply as you can, then see if it performs adequately under load. If it does, you'

Re: Question for the developers on splice

2017-03-21 Thread ToddAndMargo
On 03/21/2017 05:05 AM, Timo Paulssen wrote: Shifting from the front will just move the "beginning" pointer one slot forwards, and popping will decrease the "element count" number. I'm not sure if splice with an empty "insertion" list that happens to be at the end will also just reduce the numbe

Re: maintainability and "or"

2017-03-21 Thread Patrick R. Michaud
On Tue, Mar 21, 2017 at 02:46:43PM -0400, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 2:37 PM, Patrick R. Michaud > wrote: > > > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo > > wrote: > > > > $Name.IO.f or $Name.IO.open(:w).close; > > > > > > fwiw I consider this a perl3_to_5-ism; it's an

Re: maintainability and "or"

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 2:37 PM, Patrick R. Michaud wrote: > On Tue, Mar 21, 2017 at 02:25:02PM -0400, Brandon Allbery wrote: > > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo > wrote: > > > $Name.IO.f or $Name.IO.open(:w).close; > > > > fwiw I consider this a perl3_to_5-ism; it's an optimizatio

Re: maintainability and "or"

2017-03-21 Thread The Sidhekin
On Tue, Mar 21, 2017 at 7:28 PM, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 7:50 AM, Elizabeth Mattijsen > wrote: > >> $PathAndName.IO.open(:w).close unless $PathAndName.IO.f; > > > This has a readability issue, though: you've buried the lede. Well, to me it seems the opposite: That

Re: Is this file check backwards?

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 5:52 AM, ToddAndMargo wrote: > Sound backwards to me. What am I missing? Conditionals in all language have a semantic gap issue. Test conditions are often the reverse of what makes for good code --- which is why you find inverted conditionals in perl (e.g. unless), and

Re: maintainability and "or"

2017-03-21 Thread Patrick R. Michaud
On Tue, Mar 21, 2017 at 02:25:02PM -0400, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo wrote: > > $Name.IO.f or $Name.IO.open(:w).close; > > fwiw I consider this a perl3_to_5-ism; it's an optimization, and a fairly > poor one for readability and maintainability, but one

Re: maintainability and "or"

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 7:50 AM, Elizabeth Mattijsen wrote: > $PathAndName.IO.open(:w).close unless $PathAndName.IO.f; This has a readability issue, though: you've buried the lede. The condition should be up front where it stands out, not hidden at the back. The wide usage of the Perl 5 "or"

Re: maintainability and "or"

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo wrote: > $Name.IO.f or $Name.IO.open(:w).close; fwiw I consider this a perl3_to_5-ism; it's an optimization, and a fairly poor one for readability and maintainability, but one that used to be fairly important (people comparing perl 5 speed to perl 6

Re: Question for the developers on splice

2017-03-21 Thread Parrot Raiser
"Premature optimisation is the root of many evils", or words to that effect. (I forget who said it, but I think it was someone credible.) Write your code as clearly and simply as you can, then see if it performs adequately under load. If it does, you're finished. If it doesn't, instrument and tes

Re: maintainability and "or"

2017-03-21 Thread H.Merijn Brand
On Tue, 21 Mar 2017 12:50:18 +0100, Elizabeth Mattijsen wrote: > > On 21 Mar 2017, at 12:38, ToddAndMargo wrote: > > This is just one of those chatter posts. > > > > To me, the holy grail of coding is maintainability, > > which is why I code in Top Down. > > > > Code like below get my goat bec

Re: Question for the developers on splice

2017-03-21 Thread Timo Paulssen
Shifting from the front will just move the "beginning" pointer one slot forwards, and popping will decrease the "element count" number. I'm not sure if splice with an empty "insertion" list that happens to be at the end will also just reduce the number of elements or if it does a bit of unnecessar

Re: maintainability and "or"

2017-03-21 Thread Elizabeth Mattijsen
> On 21 Mar 2017, at 12:38, ToddAndMargo wrote: > This is just one of those chatter posts. > > To me, the holy grail of coding is maintainability, > which is why I code in Top Down. > > Code like below get my goat because I have to look > at it several times before I realize what is going on >

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 04:27 AM, Philip Hazelden wrote: $PathAndName.IO.f or $PathAndName.IO.open(:w).close; Note, the following sequence is possible: 1. .IO.f returns false 2. Someone creates the file and writes some data to it 3. .IO.open truncates the file Thus, this has a chance of editing the file

maintainability and "or"

2017-03-21 Thread ToddAndMargo
Hi All, This is just one of those chatter posts. To me, the holy grail of coding is maintainability, which is why I code in Top Down. Code like below get my goat because I have to look at it several times before I realize what is going on $Name.IO.f or $Name.IO.open(:w).close; Basically the a

Re: How to I create a file?

2017-03-21 Thread Philip Hazelden
> $PathAndName.IO.f or $PathAndName.IO.open(:w).close; Note, the following sequence is possible: 1. .IO.f returns false 2. Someone creates the file and writes some data to it 3. .IO.open truncates the file Thus, this has a chance of editing the file. I suggest instead (untested): $PathAndNam

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 04:02 AM, Simon Proctor wrote: It's a logical test but I'd probably use || instead. Thank you!

Re: How to I create a file?

2017-03-21 Thread Simon Proctor
It's a logical test but I'd probably use || instead. See : https://docs.perl6.org/language/traps#Loose_boolean_operators On Tue, 21 Mar 2017 at 10:56 ToddAndMargo wrote: > On 03/21/2017 03:07 AM, Brent Laabs wrote: > > $PathAndName.IO.f or $PathAndName.IO.open(:w).close; > > Is that a coding "

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 03:07 AM, Brent Laabs wrote: $PathAndName.IO.f or $PathAndName.IO.open(:w).close; Is that a coding "or" or an English "or"? -- ~~ Computers are like air conditioners. They malfunction when you open windows

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 03:50 AM, Simon Proctor wrote: .e checks a path exists. .f checks it exists AND is a file. .d checks it exists AND is a directory. (Perl 5 was the -e, -f and -d tests) Beautiful explanation! Thank you! Perl 5 has the (about) same test as bash and I write a lot in that too. (I

Re: How to I create a file?

2017-03-21 Thread Simon Proctor
.e checks a path exists. .f checks it exists AND is a file. .d checks it exists AND is a directory. (Perl 5 was the -e, -f and -d tests) On Tue, 21 Mar 2017 at 10:19 ToddAndMargo wrote: > On 03/21/2017 03:07 AM, Brent Laabs wrote: > > You can create a file by opening a filehandle for writing. >

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 03:07 AM, Brent Laabs wrote: You can create a file by opening a filehandle for writing. $PathAndName.IO.f or $PathAndName.IO.open(:w).close; What does the .f do? -- ~~ Computers are like air conditioners. They malfunction when you open win

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On Tue, Mar 21, 2017 at 3:01 AM, ToddAndMargo mailto:toddandma...@zoho.com>> wrote: Hi All, How to I do this bash code in Perl 6? if [ ! -f "$PathAndName" ]; then touch "$PathAndName" fi I am not finding the directions on how to create a "new" file at a specific location.

Re: How to I create a file?

2017-03-21 Thread Brent Laabs
You can create a file by opening a filehandle for writing. $PathAndName.IO.f or $PathAndName.IO.open(:w).close; On Tue, Mar 21, 2017 at 3:01 AM, ToddAndMargo wrote: > Hi All, > > How to I do this bash code in Perl 6? > > if [ ! -f "$PathAndName" ]; then touch "$PathAndName" fi > > I am not find

Re: Is this file check backwards?

2017-03-21 Thread ToddAndMargo
On Tue, 21 Mar 2017 at 09:53 ToddAndMargo mailto:toddandma...@zoho.com>> wrote: https://docs.perl6.org/language/io.html From the above manual, the example to check if a file exists: if "nonexistent_file".IO.e { say "file exists"; } else { say "file doesn'

How to I create a file?

2017-03-21 Thread ToddAndMargo
Hi All, How to I do this bash code in Perl 6? if [ ! -f "$PathAndName" ]; then touch "$PathAndName" fi I am not finding the directions on how to create a "new" file at a specific location. Many thanks, -T -- ~~ Computers are like air conditioners. They mal

Re: Question for the developers on splice

2017-03-21 Thread ToddAndMargo
On 03/21/2017 02:14 AM, Elizabeth Mattijsen wrote: On 21 Mar 2017, at 10:00, ToddAndMargo wrote: on this command: perl6 -e 'my @foo = ; @foo.splice(0,3); say @foo;' Are you actually moving one set up data into another set's element/slot/index, or are you just rearranging the pointers to each e

Re: Is this file check backwards?

2017-03-21 Thread Simon Proctor
Just because the file is called "nonexistent_file" doesn't mean is doesn't exist. It's a poorly written example really. if "possibly_existing_file".IO.e { say "file exists"; } else { say "file doesn't exist"; } Is more intuitive I would say. On Tue, 21 Mar 2017 at 09:53 ToddAndMargo

Is this file check backwards?

2017-03-21 Thread ToddAndMargo
https://docs.perl6.org/language/io.html From the above manual, the example to check if a file exists: if "nonexistent_file".IO.e { say "file exists"; } else { say "file doesn't exist"; } Sound backwards to me. What am I missing? Many thanks, -T -- ~ I

Re: Question for the developers on splice

2017-03-21 Thread Elizabeth Mattijsen
> On 21 Mar 2017, at 10:00, ToddAndMargo wrote: > on this command: > > perl6 -e 'my @foo = ; @foo.splice(0,3); say @foo;' > > Are you actually moving one set up data into another set's > element/slot/index, or are you just rearranging the pointers > to each element? How is that important? If y

Question for the developers on splice

2017-03-21 Thread ToddAndMargo
Dear Developers, on this command: perl6 -e 'my @foo = ; @foo.splice(0,3); say @foo;' Are you actually moving one set up data into another set's element/slot/index, or are you just rearranging the pointers to each element? Many thanks, -T -- ~~~ Having been erased, Th

Re: How do I remove N elements

2017-03-21 Thread ToddAndMargo
On 03/20/2017 11:18 PM, Norman Gaywood wrote: On 21 March 2017 at 15:39, ToddAndMargo mailto:toddandma...@zoho.com>> wrote: from the beginning of an array? untested but same as perl5: splice @list, 0, $N; https://docs.perl6.org/routine/splice

Re: RFE: throw an error on a single "="when used in an "if"

2017-03-21 Thread Francesco Rivetti
On 20. mars 2017 15:54, Patrick R. Michaud wrote: On Mon, Mar 20, 2017 at 02:36:49PM +0100, Francesco Rivetti wrote: On 18. mars 2017 11:54, Elizabeth Mattijsen wrote: if (my $x = frobnicate(42)) { say $x } [...] if frobnicate(42) -> $x { say $x } which is way more elegant. Should