develooper Front page | perl.perl6.users | Postings from January 2020

Re: stolen uint's

Thread Previous | Thread Next
From:
Trey Harris
Date:
January 29, 2020 02:57
Subject:
Re: stolen uint's
Message ID:
CALKJ+EszTM=mJVP66hquEEuuVV1GBnb7haeUCD9qTe_KGqn6LQ@mail.gmail.com
For doing that sort of thing, learning a little glue C would probably be
very useful (IMO, every systems-oriented programmer is helped immensely by
knowing enough C to be able to munge low-level data structures). This is a
lovely little example of a numeric library using native arithmetic where
most of the work is shunted into C but the interface is native Raku:

https://github.com/p6-pdf/Base64-Native-p6


On Tue, Jan 28, 2020 at 21:50 ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-28 18:18, Trey Harris wrote:
> > my uint $z = -32;
> > 224
>
> Another misunderstanding on my part.  I thought it
> would barf.
>
> All I really need to know is what is expected.
> To me I am getting wrong answers back, but as
> long as they are consistent answers I can deal
> with it:
>
> if $ValueData.^name  ne "Int"  || $ValueData < 0  {   # UInt gets "boxed
> to an Int
>
> Thank you for all the time you have spent with me on this!
>
> -T
>
> This all came up when I tried to match
>
>        RegSetValueExW(
>            _In_ HKEY hKey,
>            _In_opt_ LPCWSTR lpValueName,
>            _Reserved_ DWORD Reserved,
>            _In_ DWORD dwType,
>            _In_reads_bytes_opt_(cbData) CONST BYTE * lpData,
>            _In_ DWORD cbData
>
> where CbData can either be a UTF little endian C string,
> terminated by a nul or a four byte little endian
> unsigned integer (no two's complement allowed) depending
> on the value of lpValueName (REG_SZ, REG_DWORD, etc.)
>
> I wound up doing this:
>
> subset StrOrDword where Str | UInt;
> sub WinRegSetValue( WinRegHives $Hive, Str $SubKey, Str $KeyName,
> ValueNames $ValueType, StrOrDword $ValueData, Bool $Debug = False )
>                      returns DWORD is export( :WinRegSetValue ) {
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About