Re: Cardinals

2020-01-02 Thread Darren Duncan

On 2020-01-02 10:01 a.m., ToddAndMargo via perl6-users wrote:

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.


Why do you use the term "cardinal" to refer to a 32 bit unsigned integer?

The term "cardinal" in practice is just an integer/number of any magnitude with 
the added semantics of representing a quantity/count of something in contrast to 
say an ordinal position or name of something.


The term definitely does not represent a fixed-size number and it can also be 
negative.


-- Darren Duncan


Re: Cardinals

2020-01-02 Thread Todd Chester via perl6-users




On 2020-01-02 10:14, Tobias Boege wrote:

On Thu, 02 Jan 2020, ToddAndMargo via perl6-users wrote:

Hi All,

  “He who asks is a fool for five minutes, but he who
  does not ask remains a fool forever.”
  ― Mark Twain

This would be my five minutes.  I will live.

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.




It's called uint32: 
https://docs.perl6.org/language/nativetypes#index-entry-uint32



Hi Tobias,

Perfect!   Thank you!

-T


p6 'my uint16 $x = 0x8765;
my int16  $y = 0x8765;
say $x.base(0x10);
say $y.base(0x10);'

8765
-789B


p6 'my uint16 $x = 0x8765;
$x += 0xFF;
say $x.base(0x10);'

8864


p6 'my uint16 $x = 0x8765;
my int16 $y = $x +| 0x00;
say $x.base(0x10); say $y.base(0x10);'

8765
-789B


p6 'my uint16 $x = 0x4ABC;
$x = $x +< 1;
say $x.base(0x10);'
9578


p6 'my uint16 $x = 0x4ABC;
$x += $x;
say $x.base(0x10);'

9578


Re: Cardinals

2020-01-02 Thread Tobias Boege
On Thu, 02 Jan 2020, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
>  “He who asks is a fool for five minutes, but he who
>  does not ask remains a fool forever.”
>  ― Mark Twain
> 
> This would be my five minutes.  I will live.
> 
> How do I do a 32 bit unsigned integer (cardinal)?  I
> have a situation where I need to be able to have the
> first bit be a one and not have Raku think it is
> a negative number.
> 

It's called uint32: 
https://docs.perl6.org/language/nativetypes#index-entry-uint32

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


Cardinals

2020-01-02 Thread ToddAndMargo via perl6-users

Hi All,

 “He who asks is a fool for five minutes, but he who
 does not ask remains a fool forever.”
 ― Mark Twain

This would be my five minutes.  I will live.

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.

Many thanks,
-T


Re: NativeCall bug: can't find final ')'

2020-01-02 Thread ToddAndMargo via perl6-users





*From:* ToddAndMargo via perl6-users 
*Sent:* Tuesday, December 31, 2019 8:53 PM
*To:* perl6-users 
*Subject:* NativeCall bug: can't find final ')'

perl6 -I. -e "use WinReg :WinReadRegKey; say WinReadRegKey(
HKEY_LOCAL_MACHINE,
Q[SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system],
Q[EnableLUA] );"

===SORRY!=== Error while compiling K:\Windows\NtUtil\WinReg.pm6 (WinReg)

Unable to parse expression in argument list; couldn't find final ')'
(corresponding starter was at line 178) at K:\Windows\NtUtil\WinReg.pm6
(WinReg):178

--> eName, DWORD, REG_SZ, $lpData, $lpcbData is rw );
  expecting any of:
  infix
  infix stopper


"final ')' " is a bad error.   The actual error is that NativeCall does
not like the "is rw".  Please fix.

Many thanks,
-T



On 2020-01-02 08:26, Andy Bach wrote:
Just a guess, but isn't it possible that this is a quoting problem?  
Doing work from the Winx cmd line and trying to match up the 
single/double quote/multi-line mess is a way towards madness ... if you 
put your "-e" program in a file and run that, do you get a different error?


Just my 2 cents, but when ever I think I've come across a "bug" in the 
programming language, I always think again. 99.9% of the time, it's 
really me, not the language.


a




Hi Andy,

Possibly.  Probably some error in NativeCall as you
posit.

That is not the only quirk.  By default, variable in Raku
sub declarations are "is ro" (read only).  By in Native
Call, you get information back in them.  And don't
dare call them "is rw" if they are not C pointers translations,
or your will get the missing ")" error.

I am slowing writing this all down and will echo back
to the list when I get to a good stopping point.

Life in the fast lane! I could be writing in actual C.
HH  I don't know how those guys do it without
going insane.  My hat is off to them.

-T

--
~~~
Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
~~~


Re: NativeCall Doc booboo

2020-01-02 Thread ToddAndMargo via perl6-users

On 2020-01-01 19:27, Alexis wrote:


Hi Todd,

In my experience, /most/ programming languages in general use have 
0-based indexing, rather than 1 (Lua is one exception that comes to 
mind). So when dealing with a new language, i assume 0-based indexing, 
unless explicitly told otherwise. Regardless, any decent introduction to 
the basics of C will mention its 0-based indexing.


Hi Alexis,

The last programming language I used, but not the first,
was Perl 5.  In Perl 5 you have to be careful what starts
at 0 and what starts at 1.  It took me about a
years to quit goofing `m/` in raku as it starts at
$1 in Perl 5.  Oh I goofed that so, so many times!

:'(





You presume "C" programming knowledge from Raku programmers. ...
So "is left as an exercise to the student" means the student
should first take a course in "C" programming to get around
all the goofs and oversights in the documentation?


i think what's being presumed is that if one is accessing C-based 
functionality, one has to know or learn at least the basics of C. This 
is no different from documentation presuming that if you're calling out 
to a shell from Raku, you'll read the shell documentation to learn how 
the latter works. The volunteers working on Raku have enough on their 
plates as it is; expecting that they should write an tutorial on the 
basics of C, when there's already a plethora of such resources available 
elsewhere, seems like an inefficient use of their time.


Yes and no.  If you are going to write a module that
interfaces with C, than you really should put down a
least some information as to how to do that.

I am constantly refining my NativeCall notes.  When I
am finished or close.  I will echo  them back here next
time.  It will show WinAPI calls, what the variable mean,
and how to interface with them.  Hopefully it will
be of some use to others and the overworked developers.

Am I coming across negatively that I sometimes post
these keepers of mine?

your words regularly seem to be belied by 
your actions. 


I am not sure where that is coming from, but I will
definitely be more careful with my wording in the
future.  Please tag me if you catch me out of line.
I really intend no harm to those that constantly
help me. Thank you for the heads up.

I also do constantly check this list to see if I can help
others -- pay back for the help I have been given.  In
the future I will get much better at it as I get better
myself and hopefully be more on the giving end than the receiving end. 
It is more fun to help than to receive.



Alexis.


Re: NativeCall bug: can't find final ')'

2020-01-02 Thread Andy Bach
Just a guess, but isn't it possible that this is a quoting problem?  Doing work 
from the Winx cmd line and trying to match up the single/double 
quote/multi-line mess is a way towards madness ... if you put your "-e" program 
in a file and run that, do you get a different error?

Just my 2 cents, but when ever I think I've come across a "bug" in the 
programming language, I always think again. 99.9% of the time, it's really 
me, not the language.

a


From: ToddAndMargo via perl6-users 
Sent: Tuesday, December 31, 2019 8:53 PM
To: perl6-users 
Subject: NativeCall bug: can't find final ')'


perl6 -I. -e "use WinReg :WinReadRegKey; say WinReadRegKey(
HKEY_LOCAL_MACHINE,
Q[SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system],
Q[EnableLUA] );"

===SORRY!=== Error while compiling K:\Windows\NtUtil\WinReg.pm6 (WinReg)

Unable to parse expression in argument list; couldn't find final ')'
(corresponding starter was at line 178) at K:\Windows\NtUtil\WinReg.pm6
(WinReg):178

--> eName, DWORD, REG_SZ, $lpData, $lpcbData is rw );
 expecting any of:
 infix
 infix stopper


"final ')' " is a bad error.   The actual error is that NativeCall does
not like the "is rw".  Please fix.

Many thanks,
-T