Re: Ping JJ: string literals

2020-01-18 Thread JJ Merelo
I know this is utterly and absolutely absurd, but so it goes. El vie., 17 ene. 2020 a las 23:28, ToddAndMargo () escribió: > Hi JJ, > > Please be my hero. > > I won't call you any goofy names out of > affection and friendship, as others will get > their nickers in a twist. > > This is from a prev

Re: Ping JJ: string literals

2020-01-18 Thread Tobias Boege
On Sat, 18 Jan 2020, JJ Merelo wrote: > The example works perfectly, and it does because it's a string literal > which is already 0 terminated. Let's use this code instead of the one that > I used in my other mail about this (which you probably didn't read anyway): > > 8< 8< 8< > > What does this

Re: Ping JJ: string literals

2020-01-18 Thread JJ Merelo
El sáb., 18 ene. 2020 a las 13:55, Tobias Boege () escribió: > On Sat, 18 Jan 2020, JJ Merelo wrote: > > The example works perfectly, and it does because it's a string literal > > which is already 0 terminated. Let's use this code instead of the one > that > > I used in my other mail about this (w

Re: problems with xor

2020-01-18 Thread Tobias Boege
On Fri, 17 Jan 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > https://docs.raku.org/routine/+$CIRCUMFLEX_ACCENT > > (Operators) infix +^§ > > multi sub infix:<+^>($a, $b --> Int:D) > > Integer bitwise XOR operator: Coerces both arguments to Int and does a > bitwise XOR (exclusive OR) o

Re: Ping JJ: string literals

2020-01-18 Thread Paul Procacci
Thank you Tobias. This is what I was trying to get at, but wasn't sure _how_ to reach that conclusion. You've done so elegantly. ~Paul On Sat, Jan 18, 2020 at 7:55 AM Tobias Boege wrote: > On Sat, 18 Jan 2020, JJ Merelo wrote: > > The example works perfectly, and it does because it's a string

Re: problems with xor

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-17 22:26, Darren Duncan wrote: On 2020-01-17 9:00 p.m., ToddAndMargo via perl6-users wrote: Still don't know what they used the word "sub" The term "sub" is short for "subroutine", and declaring routines that way is part of the Perl legacy that lasted into Raku. -- Darren Duncan

Re: problems with xor

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 06:09, Tobias Boege wrote: On Fri, 17 Jan 2020, ToddAndMargo via perl6-users wrote: Hi All, https://docs.raku.org/routine/+$CIRCUMFLEX_ACCENT (Operators) infix +^§ multi sub infix:<+^>($a, $b --> Int:D) Integer bitwise XOR operator: Coerces both arguments to Int and does a bitw

definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
Hi All, Okay, I clearly do not understand what is going on with these definitions, so please correct my assumptions! https://docs.raku.org/language/operators#infix_+ https://docs.raku.org/routine/+$CIRCUMFLEX_ACCENT Question: would some kind soul please tell me how: multi sub infix:<+>($

Re: definition confusion of + and +^

2020-01-18 Thread Veesh Goldman
Hi Todd, I would suggest reading https://docs.raku.org/language/optut. For a slightly more thorough read https://docs.raku.org/language/functions#Defining_operators. On Sat, Jan 18, 2020 at 10:39 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > Okay, I clearly do not

Re: definition confusion of + and +^

2020-01-18 Thread Curt Tilmes
On Sat, Jan 18, 2020, 3:39 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > 4) infix:<+> means you can call it as a sub that > gives you back the wrong answer. > > $c = +($a, $b) > $c = +^($a, $b) > You left off the infix:<> part of the sub's name.

Re: definition confusion of + and +^

2020-01-18 Thread Brad Gilbert
Most operators in Raku are subroutines. 1 + 2 infix:<+>( 1, 2 ) -1 prefix:<->( 1 ) You can add your own operators by creating such a subroutine. sub postfix: ( UInt \n ) { [×] 2..n } say 5!; # 120 Because it is so easy to add operators. Operators only do one thing.

Re: problems with xor

2020-01-18 Thread Kevin Pye
As has been explained quite explicitly twice already, you call it as a sub by using the full explicit name of the subroutine: $z = infix:<+^>($x, $y) On Sun, 19 Jan 2020 at 07:22, ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-01-18 06:09, Tobias Boege wrote: > > On Fri,

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 13:11, Marcel Timmerman wrote:     my $a=2; my $b=3; my $c = +($a, $b) Here is the mistake that + in front of a list means (...).elems (also used as a prefix, not infix), so there are 2 items in the list which is true. So '+(1,2,3)' returns 3 and '+(^10)' is 10 and '+(5..10

Re: problems with xor

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 13:25, Kevin Pye wrote: As has been explained quite explicitly twice already, you call it as a sub by using the full explicit name of the subroutine: $z = infix:<+^>($x, $y) Hi Kevin, My mistake was thinking "infix" was part of the description of how to write the sub, not acuta

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 13:10, Veesh Goldman wrote: Hi Todd, I would suggest reading https://docs.raku.org/language/optut. This one starts out with: Operators are declared by using the sub keyword followed by prefix, infix, postfix, circumfix, or postcircumfix; then a colon and the operator

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 13:16, Brad Gilbert wrote: Most operators in Raku are subroutines.     1 + 2     infix:<+>( 1, 2 )     -1     prefix:<->( 1 ) My mistake was thinking `infix:<+>` meqan to put the `+` before the `)` Note that Int:D does NOT do any coercions. Int:D() does do coercions.

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 13:16, Curt Tilmes wrote: On Sat, Jan 18, 2020, 3:39 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: 4)  infix:<+> means you can call it as a sub that      gives you back the wrong answer.          $c = +($a, $b)          $c = +^($a, $b

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 13:16, Brad Gilbert wrote: Note that Int:D does NOT do any coercions. Int:D() does do coercions. Specifically Int:D() is short for Int:D(Any). Which means it coerces from Any to Int, and the result must be defined. Does the same apply to UInt:D and UInt:D()?

Re: definition confusion of + and +^

2020-01-18 Thread Elizabeth Mattijsen
> On 19 Jan 2020, at 00:24, ToddAndMargo via perl6-users > wrote: > Wonderful so far. But then he DOES not describe what > "infix, prefix, postfix, circumfix, postcircumfix" > arfe/means before jumping into details. This is bad > form in technical writing. s/he/it/ > Again, wonderful so far.

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 15:59, Elizabeth Mattijsen wrote: infix: foo + bar prefix:+foo postfix: foo++ circumfix: [foo] postcircumfix: foo[bar] Hi Liz, You are still putting the cart before the horse. This is the step you jumped over: An "infix" is a term that ... You mis

my keeper on bitwise operations

2020-01-18 Thread ToddAndMargo via perl6-users
Hi All, My keeper on bitwise operations: -T Perl: bitwise operators: alias p5='perl6 -E' alias p6='perl6 -e' Shift Left and OR: $ p6 'my Buf $x=Buf.new(0xAE,0x5D,0x5C,0x72); my int32 $i=$x[3] +< 0x18 +| $x[2] +< 0x10 +| $x[1] +< 0x08 +| $x[0]; say $x; say $i

Re: my keeper on bitwise operations

2020-01-18 Thread Elizabeth Mattijsen
> On 19 Jan 2020, at 01:15, ToddAndMargo via perl6-users > wrote: > alias p5='perl6 -E' s/perl6/perl/

Using raku/perl6 as unix "cat"....

2020-01-18 Thread William Michels via perl6-users
Hello All, I've been reviewing literature that discusses using raku/perl6 as a replacement for common unix utilities. One important unix utility is "cat". I looked at docs/blogs and found a recommendation to use "$*IN" along with "slurp" (references at bottom). Using a seven-line test file "testth

Re: my keeper on bitwise operations

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 16:26, Elizabeth Mattijsen wrote: On 19 Jan 2020, at 01:15, ToddAndMargo via perl6-users wrote: alias p5='perl6 -E' s/perl6/perl/ Great catch. Thank you! Perl: bitwise operators: alias p5='perl -E' alias p6='perl6 -e' -- ~~ Computer

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
Hi All, Thank you all for the wonderful help on this. What I am still confused about is how to read these silly definition lines: multi sub infix:<+>($a, $b --> Numeric:D) multi sub infix:<+^>($a, $b --> Int:D) How exactly does the above tell me to do this? $c = $a +  $b

Re: Using raku/perl6 as unix "cat"....

2020-01-18 Thread yary
"while" is the wrong looping construct for going over file lines, and that's across a great many computer languages. It will stop when it encounters a false line- typically an empty line or '0' Try "for" -y On Sat, Jan 18, 2020 at 4:45 PM William Michels wrote: > Hello All, > > I've been revi

Re: definition confusion of + and +^

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 15:59, Elizabeth Mattijsen wrote: s/he/it/ The idea that no gentleman ever swears is all wrong. He can swear and still be a gentleman, if he does it in a nice and benevolent and affectionate way. --Mark Twain - Private and Public Morals speech, 1906 :-)

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
Would you be so kind to post this as an issue in the documentation, so we can pick up on it? Thanks! JJ Would you mind posting back the link to it, so I can get on the following list?

Re: Using raku/perl6 as unix "cat"....

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 17:54, yary wrote: "while" is the wrong looping construct for going over file lines, and that's across a great many computer languages. It will stop when it encounters a false line- typically an empty line or '0' Try "for" -y Hi William, I don't know if this will help you, b

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 04:55, Tobias Boege wrote: BUT the terminating NUL character is not inserted by NativeCall and it isn't inserted by &encode. Hi Tobias, I found this out the hard way. I also found out the hard wasy the UTF16 strings need to be terminated with a double nul (0x). -T

Re: Ping JJ: string literals

2020-01-18 Thread Paul Procacci
>> I also found out the >> hard wasy the UTF16 strings need to be terminated with >> a double nul (0x). Not to doubt you (I don't do anything in UTF-16), but can you show an example of this? I would have thought a single NULL character is enough. The 1st byte of a Unicode character determines

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 20:05, Paul Procacci wrote: >> I also found out the >> hard wasy the UTF16 strings need to be terminated with >> a double nul (0x). Not to doubt you (I don't do anything in UTF-16), but can you show an example of this? I would have thought a single NULL character is enough

Re: Ping JJ: string literals

2020-01-18 Thread yary
In UTF-16 every character is 16 bits, so all 8 bits of zeros tells you is that it's possibly a big-endian ascii character or a little-endian non-ascii character at a position divisible by 256. All zeros U+ is unicode NULL, which the windows UTF-16 C convention uses to terminate the string. -y

Re: Ping JJ: string literals

2020-01-18 Thread Paul Procacci
Perfect. Obviously didn't know that. My assumption that only the first byte gets checked was obviously wrong. Thanks gents. On Sun, Jan 19, 2020 at 12:12 AM yary wrote: > In UTF-16 every character is 16 bits, so all 8 bits of zeros tells you is > that it's possibly a big-endian ascii characte

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 21:04, ToddAndMargo via perl6-users wrote: I changed the initialization of the buffer from 0x00 to 0xFF to make the double nul at the end a bit more obvious: # my BYTES $lpBuffer = CArray[BYTE].new( 0 xx $nSize ); my BYTES $lpBuffer = CArray[BYTE].new( 0xFF xx $nSize );

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 21:20, Paul Procacci wrote: Perfect.  Obviously didn't know that.  My assumption that only the first byte gets checked was obviously wrong. Thanks gents. This is the way I dig out the ascii characters from the word array. $nSize comes back from function call. loop (my $Inde

Re: Ping JJ: string literals

2020-01-18 Thread Paul Procacci
Sorry. Not a WINAPI expert, nor do I want to be. ;) The $nSize variable looks fishy. Can it ever contain a value that's <= 2? If so, you're in for a surprise one day. ;) Bedtime. ~Paul On Sun, Jan 19, 2020 at 12:28 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-01

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 21:42, Paul Procacci wrote: Sorry.  Not a WINAPI expert, nor do I want to be.  ;) No Welcome to the Dar Side for you!!! :-) The $nSize variable looks fishy.  Can it ever contain a value that's <= 2? The buffer always has some size to it. Maybe not. This is is what it looks

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 21:49, ToddAndMargo via perl6-users wrote: On 2020-01-18 21:42, Paul Procacci wrote: Sorry.  Not a WINAPI expert, nor do I want to be.  ;) No Welcome to the Dar Side for you!!! :-) The $nSize variable looks fishy.  Can it ever contain a value that's <= 2? The buffer always

Re: Ping JJ: string literals

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 21:42, Paul Procacci wrote: Sorry.  Not a WINAPI expert, nor do I want to be.  ;) The $nSize variable looks fishy.  Can it ever contain a value that's <= 2? If so, you're in for a surprise one day.  ;) Bedtime. ~Paul Hi Paul, Great catch. Thank you for the peer preview! -T