Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 22:56, Darren Duncan wrote:
Brad is saying what I've been saying, while a uint CAN represent a 
cardinal number, one does NOT ALWAYS represent a cardinal number, so 
saying this only IS a cardinal number is WRONG. -- Darren Duncan


Hi Darren,

You are mixing specific data constructions with generic
arithmetic and programming terms.

The Raku uint series of natives and UInt in Raku
are all cardinals.  Raku and assembly code like
to call them "unsigned integers".  Other languages
freely use the term Cardinal.  Both names are the
same thing.  The difference is that one is quicker
to spell, that is all.  Pick which either name
your like.

Since Raku uses the term "unsigned integers" for the
family of numbers that cardinals belong to, it is
probably best to call them "unsigned integers" so as
to not cause the confusing/consternation I caused.

$ p6 'my UInt $c = -4;'
Type check failed in assignment to $c; expected UInt but
got Int (-4) in block  at -e line 1

You can get away with a standard uint as Raku will
flip the type on you on the fly.  It won't flip
a UInt as it is a subset.

Now if you want to talk specific data constructions:
an int8 is not an int16, even though both are
"generic term" integers.  And an uint16 is not a
uint32 even though the are all "generic
term" cardinals / unsigned integers, whichever
name you picked.

When you hear me say "cardinal", think he is talking
about a family of numbers, not a specific data
construction.

Oh and Raku has an unbounded by byte length cardinal
called a UInt.  Any byte length goes and way, way
past 64 bits if you want.  Now that is a machine
language abomination and I LOVE IT!  Damn Larry
is cleaver!

-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Darren Duncan

On 2020-01-12 11:32 p.m., ToddAndMargo via perl6-users wrote:

On 2020-01-12 20:03, Darren Duncan wrote:

A uint32 is NOT specifically a cardinal.


Since a uint32 ca not be negative or a fraction,
it is a cardinal.  Other operating system do call
them cardinals, such as Modula2. Pascal, C++ (I
think C too), Java, and so on and so forth.


Yes, a uint32 CAN represent a cardinal, but it can ALSO represent an ordinal or 
a nominal or various other things.


A uint32 is just as much an ordinal as a cardinal, so insisting on calling it 
a cardinal means the type can't be used as an ordinal, or a variety of other 
things.


https://www.dictionary.com/browse/ordinal-number
    ordinal number
    noun
    Also called ordinal numeral. any of the numbers that
    express degree, quality, or position in a series, as
    first, second, and third *(distinguished from cardinal
    number)*.

    Mathematics. a symbol denoting both the cardinal number
    and the ordering of a given set, being identical for
    two ordered sets having elements that can be placed
    into one-to-one correspondence, the correspondence
    preserving the order of the elements.

https://www.dictionary.com/browse/cardinal-number
    cardinal number
    noun
    Also called cardinal numeral. any of the numbers
    that express amount, as one, two, three, etc.
    *(distinguished from ordinal number)*.

No idea how you are mixing these two.  I can see
how yo would use a cardinal in programming to
denote an ordinal, if that is what you are getting at.


These are different semantics applied to the same representations.

You tell me, take the following sequence:

0, 1, 2, 3, 4, ...

Does that sequence denote cardinals, or ordinals, or both, or something else?

I would say both.  If you say it is only cardinals or only ordinals, then how do 
you determine that it is just one and not the other.


Calling this an unsigned integer (u int) is much more accurate as it doesn't 
presume a particular semantics such as that we are storing a count rather than 
a position for example, it says what we actually know, and no more.


I am sorry, I have no idea what you are trying to say.  I do not care if you 
call a cardinal an unsigned integer.  Just

don't call it an integer.  The high bit in a cardinal is
part of the number and denotes a negative number in an integer.


What high bit?  We're talking about mathematical definitions here, that's what 
you're quoting from Wikipedia.  Cardinals and ordinals and integers etc don't 
have "bits" in mathematics, never mind a high bit.


The way I see it, you are making the mistake of confusing mathematical concepts 
with possible representations for them in a computer.  A cardinal or ordinal or 
integer is a mathematical concept that is not defined in terms of bits.  Each of 
these has possible representations in a computer as a sequence of bits.  The 
same bit pattern that a uint32 holds can possibly represent either a cardinal or 
an ordinal but is not a cardinal or an ordinal itself.


You are also wrong on saying that the values one can store in a uint32 are not 
integers; they definitely ARE integers.  Every cardinal is an integer.


Where do you get that.  A cardinal can not be negative.  An
Integer can.  And the structure is even different:  the high
bit in an integer denote the sign of the integer; the high bit
in a cardinal is just a higher positive number.  So they
are not the same by any shake.


Again, take the following:

0, 1, 2, 3, 4, ...

I say that each of these is both a cardinal AND an integer.  True that a 
cardinal can not be negative, but both a cardinal and an integer CAN be 
positive, so any positive whole number IS an integer just as it also IS a cardinal.


-- Darren Duncan


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Darren Duncan
Brad is saying what I've been saying, while a uint CAN represent a cardinal 
number, one does NOT ALWAYS represent a cardinal number, so saying this only IS 
a cardinal number is WRONG. -- Darren Duncan


On 2020-01-13 12:56 p.m., Brad Gilbert wrote:

Ok looking into it, zero is inside of the set of cardinal numbers.

It is still wrong to call a uint a cardinal number.
It's just wrong for a different reason.

Looking through various definitions, a cardinal number is a number which 
represents a count of sets.


So a uint could be used to represent a cardinal number, but it could just as 
easily be a number that represents something other than a count.


If it is being used to index into a list it would be an ordinal number. (And so 
definitely not a cardinal number.)


Calling them cardinal numbers would imply something about them that may or may 
not be true.


If it is being used to store a bitmask, then it would be wrong to call it a 
cardinal, ordinal, or even a natural number.


It may also be wrong to call it an integer, but at least that is what CPU 
designers call it.


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 21:02, Aureliano Guedes wrote:
ToddAndMargo, this should handle any kind of columns separated data (or 
any table). If some column (commonly separated with a constant character 
as "\t", ";", "|", )  has different types (char, text, int, boolean, 
...) in a single column, then it should be treated as a character, but 
if it has only float (in all rows/lines) then the parser checks all rows 
for a same column (in this example case all them are float) and assign 
the column as float contain column.

Example:

NAME(long char);NICK(char);AGE(natural/positive
integer);HEIGHT(float m);WEIGHT(float kg)

John Lovegood;JoL;23;1.80;85.283

Marry Lockheart;Marry_L;35;1.68;63,125

You may see that the first line must be a header, all lines have 5 
fields separated by ";" and each field has a unique type (the 
specifications not aways be declared on the data or file).


How are you getting this data back?  In a buffer of
DWORDS that you have to cut up?  Or are they already
formatted for you?


Re: bitwise NOT

2020-01-13 Thread ToddAndMargo via perl6-users
On Mon, Jan 13, 2020 at 11:30 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


Hi All,

This works,

 $ p6 'my uint8 $c = 0xA5; my uint8 $d =  +^$c; say $d.base(16);'
 5A

But this does not:

 $ p6 'my uint8 $c = 0xA5; say (+^$c).base(16);'
 -A6

1) who turned it into an negative integer?

2) how do I turn it back?

Many thanks,
-T


On 2020-01-13 21:18, Paul Procacci wrote:

If you read the signature for +^, you'll notice it returns an Int.

In your first working example, you're taking a uint8 with binary value 
10100101, zero extending it to 64 bits via +^, applying a two's 
compliment, and then assigning bits [0:7] to another uint8 which at that 
point contains the binary value of 01011010 (or hex value 0x5A).
In your second example that isn't working, you're taking uint8 with 
binary value 10100101, zero extending it to 64 bits via +^, applying a 
two's compliment, and then displaying this *Int* (64 bits) as hex.[1]
To turn it back you need to mask off bits [8:63] with: say ((+^$e) +& 
0x0FF).base(16);" [2]


[1] I'd show you the 64 bit value but it's a bunch of 1's followed by 
the value -0xA6.
[2] Note, since the type has been promoted to an Int there' no going 
back to uint8 without an explicit assignment (afaik)




That explains it.  Thank you.

I used uint8 to keep the ones to a mild torrent!

If I am remembering correctly, 0xA5 going to 0x5A is
a ones compliment.

What is the syntax for a twos complement anyway?


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 21:02, Aureliano Guedes wrote:
ToddAndMargo, this should handle any kind of columns separated data (or 
any table). If some column (commonly separated with a constant character 
as "\t", ";", "|", )  has different types (char, text, int, boolean, 
...) in a single column, then it should be treated as a character, but 
if it has only float (in all rows/lines) then the parser checks all rows 
for a same column (in this example case all them are float) and assign 
the column as float contain column.

Example:

NAME(long char);NICK(char);AGE(natural/positive
integer);HEIGHT(float m);WEIGHT(float kg)

John Lovegood;JoL;23;1.80;85.283

Marry Lockheart;Marry_L;35;1.68;63,125

You may see that the first line must be a header, all lines have 5 
fields separated by ";" and each field has a unique type (the 
specifications not aways be declared on the data or file).






Consider an array of hashes:

my Str  $Name;
my Str  $NickName;
my uint $Age;
my num  $Height;
my num  $Weight;
my  @Members;

my %Person= ( Name=> $Name, NickName => $NickName, Age=> $Age, Height=> 
$Height, Weight=> $Weight );


Then you can use "push" to create an array of hashes on to @Members as 
you read in each member.


push @Members, %Person;


Re: bitwise NOT

2020-01-13 Thread Paul Procacci
 If you read the signature for +^, you'll notice it returns an Int.

In your first working example, you're taking a uint8 with binary value
10100101, zero extending it to 64 bits via +^, applying a two's compliment,
and then assigning bits [0:7] to another uint8 which at that point contains
the binary value of 01011010 (or hex value 0x5A).
In your second example that isn't working, you're taking uint8 with binary
value 10100101, zero extending it to 64 bits via +^, applying a two's
compliment, and then displaying this *Int* (64 bits) as hex.[1]
To turn it back you need to mask off bits [8:63] with: say ((+^$e) +&
0x0FF).base(16);" [2]

[1] I'd show you the 64 bit value but it's a bunch of 1's followed by the
value -0xA6.
[2] Note, since the type has been promoted to an Int there' no going back
to uint8 without an explicit assignment (afaik)

On Mon, Jan 13, 2020 at 11:30 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> This works,
>
> $ p6 'my uint8 $c = 0xA5; my uint8 $d =  +^$c; say $d.base(16);'
> 5A
>
> But this does not:
>
> $ p6 'my uint8 $c = 0xA5; say (+^$c).base(16);'
> -A6
>
> 1) who turned it into an negative integer?
>
> 2) how do I turn it back?
>
> Many thanks,
> -T
>


-- 
__

:(){ :|:& };:


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Aureliano Guedes
ToddAndMargo, this should handle any kind of columns separated data (or any
table). If some column (commonly separated with a constant character as
"\t", ";", "|", )  has different types (char, text, int, boolean, ...)
in a single column, then it should be treated as a character, but if it has
only float (in all rows/lines) then the parser checks all rows for a same
column (in this example case all them are float) and assign the column as
float contain column.
Example:

NAME(long char);NICK(char);AGE(natural/positive integer);HEIGHT(float
m);WEIGHT(float kg)

John Lovegood;JoL;23;1.80;85.283

Marry Lockheart;Marry_L;35;1.68;63,125

You may see that the first line must be a header, all lines have 5 fields
separated by ";" and each field has a unique type (the specifications not
aways be declared on the data or file).


Paul Proacci, thank you for a lot. I agree with you. Then, float, integer,
boolean and char are the most commons and probably better to assign. But
persist the question, which is the best strategy to define with which type
assign some column?

On Mon, Jan 13, 2020 at 11:28 PM Paul Procacci  wrote:

> >> what is the best strategy?
>
> My general rule of thumb:
>
> If you control the value then you can pick whatever data type that has the
> largest number of bits to hold your largest value.[1]
> If you don't control the value, stick with an Int (or Uint).
>
> If you stick with Int you can later modify it to use more tailor made type
> as necessary, but Int is always going to be the safest bet.
>
> Hope this helps you.
>
> [1] I never use unsigned variants of integers where arithmetic may be
> involved do to overflow and use variants of signed integers instead
> whenever possible.
>
> On Mon, Jan 13, 2020 at 11:09 PM Aureliano Guedes <
> guedes.aureli...@gmail.com> wrote:
>
>> About the Raku typing, suppose I'll write a library to deal with data
>> frames/tables (as PDL - Perl(5) Data Language), something like
>> Pandas-Python or R.
>> After reading the file (csv; tsv ) I'd like that some routine
>> identifies the best type to fix each column (especially in cases like Unit,
>> unit, int, ) what is the best strategy?
>>
>> On Mon, Jan 13, 2020 at 10:51 PM ToddAndMargo via perl6-users <
>> perl6-users@perl.org> wrote:
>>
>>> >> On Mon, Jan 13, 2020 at 9:51 PM ToddAndMargo via perl6-users
>>> >> mailto:perl6-users@perl.org>> wrote:
>>> >>
>>> >> On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:
>>> >>  > On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:
>>> >>  >> And, no one is telling me percisely what the difference
>>> >>  >> between UInt and uint is other than one is a subset of
>>> >>  >> Int and the other is a native type.  They act exactly
>>> >>  >> the same.
>>> >>  >
>>> >>  > Hi All,
>>> >>  >
>>> >>  > Off line, Paul told me what the difference is
>>> >>  > between a UInt and a uint.
>>> >>  >
>>> >>  > uint is constrained:
>>> >>  >
>>> >>  >  p6 'my uint $c = 0x0; $c = $c +| 0x1;'
>>> >>  >  Cannot unbox 65 bit wide bigint into native integer
>>> >>  >   in block  at -e line 1
>>> >>  >
>>> >>  > UInt uses magic Larry Wall powder to remove the constraints
>>> >>  > from the variable.  (Same powder he uses to create nils.)
>>> >>  >
>>> >>  >  p6 'my UInt $c = 0x0; $c = $c +|
>>> >>  > 0x1F;
>>> say
>>> >> $c'
>>> >>  >
>>> 862718293348820473429344482784628181556388621521298319395315527974911
>>> >>  >
>>> >>  > Other than the constrains, they act exactly the same.
>>> >>  > Oh, and they are both (generic programming term) unsigned
>>> integers
>>> >>  > (cardinals)
>>> >>  >
>>> >>  > :-)
>>> >>  >
>>> >>  > -T
>>> >>
>>> >>
>>> >> And good luck, all you who told me to read the
>>> >> documentation, trying to find the constraints
>>> >> explanation in the documentation:
>>> >>
>>> >> https://docs.raku.org/type/UInt
>>> >>
>>> >> Have fun!
>>> >>
>>> >> But it does say "The UInt is defined as a subset of Int:"
>>> >> and Int is definitely constrained.
>>> >>
>>>
>>> On 2020-01-13 19:13, Paul Procacci wrote:
>>> >  >> trying to find the constraints explanation in the documentation:
>>> >
>>> > https://docs.raku.org/language/nativetypes
>>> >
>>> > "Raku offers a set of /native/ types with a fixed, and known,
>>> > representation in memory"
>>> > and
>>> > "However, these types do not necessarily have the size that is
>>> required
>>> > by the NativeCall 
>>> interface
>>> > (e.g., Raku's |int| can be 8 bytes but C's |int| is only 4 bytes)"
>>> >
>>> > Took me all of 30 seconds to find.  Obviously that page has much more
>>> > information to offer than just those couple of sentences, but ALL
>>> native
>>> > types are constrained by a certain number of bits.
>>>
>>>
>>> Hi 

bitwise NOT

2020-01-13 Thread ToddAndMargo via perl6-users

Hi All,

This works,

   $ p6 'my uint8 $c = 0xA5; my uint8 $d =  +^$c; say $d.base(16);'
   5A

But this does not:

   $ p6 'my uint8 $c = 0xA5; say (+^$c).base(16);'
   -A6

1) who turned it into an negative integer?

2) how do I turn it back?

Many thanks,
-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Paul Procacci
>> what is the best strategy?

My general rule of thumb:

If you control the value then you can pick whatever data type that has the
largest number of bits to hold your largest value.[1]
If you don't control the value, stick with an Int (or Uint).

If you stick with Int you can later modify it to use more tailor made type
as necessary, but Int is always going to be the safest bet.

Hope this helps you.

[1] I never use unsigned variants of integers where arithmetic may be
involved do to overflow and use variants of signed integers instead
whenever possible.

On Mon, Jan 13, 2020 at 11:09 PM Aureliano Guedes <
guedes.aureli...@gmail.com> wrote:

> About the Raku typing, suppose I'll write a library to deal with data
> frames/tables (as PDL - Perl(5) Data Language), something like
> Pandas-Python or R.
> After reading the file (csv; tsv ) I'd like that some routine
> identifies the best type to fix each column (especially in cases like Unit,
> unit, int, ) what is the best strategy?
>
> On Mon, Jan 13, 2020 at 10:51 PM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> >> On Mon, Jan 13, 2020 at 9:51 PM ToddAndMargo via perl6-users
>> >> mailto:perl6-users@perl.org>> wrote:
>> >>
>> >> On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:
>> >>  > On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:
>> >>  >> And, no one is telling me percisely what the difference
>> >>  >> between UInt and uint is other than one is a subset of
>> >>  >> Int and the other is a native type.  They act exactly
>> >>  >> the same.
>> >>  >
>> >>  > Hi All,
>> >>  >
>> >>  > Off line, Paul told me what the difference is
>> >>  > between a UInt and a uint.
>> >>  >
>> >>  > uint is constrained:
>> >>  >
>> >>  >  p6 'my uint $c = 0x0; $c = $c +| 0x1;'
>> >>  >  Cannot unbox 65 bit wide bigint into native integer
>> >>  >   in block  at -e line 1
>> >>  >
>> >>  > UInt uses magic Larry Wall powder to remove the constraints
>> >>  > from the variable.  (Same powder he uses to create nils.)
>> >>  >
>> >>  >  p6 'my UInt $c = 0x0; $c = $c +|
>> >>  > 0x1F;
>> say
>> >> $c'
>> >>  >
>> 862718293348820473429344482784628181556388621521298319395315527974911
>> >>  >
>> >>  > Other than the constrains, they act exactly the same.
>> >>  > Oh, and they are both (generic programming term) unsigned
>> integers
>> >>  > (cardinals)
>> >>  >
>> >>  > :-)
>> >>  >
>> >>  > -T
>> >>
>> >>
>> >> And good luck, all you who told me to read the
>> >> documentation, trying to find the constraints
>> >> explanation in the documentation:
>> >>
>> >> https://docs.raku.org/type/UInt
>> >>
>> >> Have fun!
>> >>
>> >> But it does say "The UInt is defined as a subset of Int:"
>> >> and Int is definitely constrained.
>> >>
>>
>> On 2020-01-13 19:13, Paul Procacci wrote:
>> >  >> trying to find the constraints explanation in the documentation:
>> >
>> > https://docs.raku.org/language/nativetypes
>> >
>> > "Raku offers a set of /native/ types with a fixed, and known,
>> > representation in memory"
>> > and
>> > "However, these types do not necessarily have the size that is required
>> > by the NativeCall 
>> interface
>> > (e.g., Raku's |int| can be 8 bytes but C's |int| is only 4 bytes)"
>> >
>> > Took me all of 30 seconds to find.  Obviously that page has much more
>> > information to offer than just those couple of sentences, but ALL
>> native
>> > types are constrained by a certain number of bits.
>>
>>
>> Hi Paul,
>>
>> For those of you who were no privy to Paul and my
>> offline discussion, he must have wrote me 10
>> times trying to explain things to me before
>> I got it.  He is a real mensch.
>>
>> 30 seconds!  Yikes!  I never found it.
>>
>> https://docs.raku.org/type/UInt
>> should have stated that directly, but did not.
>>
>> And to add injury,
>>
>> https://docs.raku.org/language/nativetypes
>>  "Raku offers a set of /native/ types with a fixed,
>>  and known, representation in memory"
>>
>> Did not state who they were.  Sort of like when I
>> want the  salt, I always reach for the pepper!
>>
>> The state of the documentation drives me  ...
>>
>>  AAHH! 
>>
>> -T
>>
>
>
> --
> Aureliano Guedes
> skype: aureliano.guedes
> contato:  (11) 94292-6110
> whatsapp +5511942926110
>


-- 
__

:(){ :|:& };:


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 20:09, Aureliano Guedes wrote:
About the Raku typing, suppose I'll write a library to deal with data 
frames/tables (as PDL - Perl(5) Data Language), something like 
Pandas-Python or R.
After reading the file (csv; tsv ) I'd like that some routine 
identifies the best type to fix each column (especially in cases like 
Unit, unit, int, ) what is the best strategy?



Would you give us an example of what the data looks like?


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Aureliano Guedes
About the Raku typing, suppose I'll write a library to deal with data
frames/tables (as PDL - Perl(5) Data Language), something like
Pandas-Python or R.
After reading the file (csv; tsv ) I'd like that some routine
identifies the best type to fix each column (especially in cases like Unit,
unit, int, ) what is the best strategy?

On Mon, Jan 13, 2020 at 10:51 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> >> On Mon, Jan 13, 2020 at 9:51 PM ToddAndMargo via perl6-users
> >> mailto:perl6-users@perl.org>> wrote:
> >>
> >> On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:
> >>  > On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:
> >>  >> And, no one is telling me percisely what the difference
> >>  >> between UInt and uint is other than one is a subset of
> >>  >> Int and the other is a native type.  They act exactly
> >>  >> the same.
> >>  >
> >>  > Hi All,
> >>  >
> >>  > Off line, Paul told me what the difference is
> >>  > between a UInt and a uint.
> >>  >
> >>  > uint is constrained:
> >>  >
> >>  >  p6 'my uint $c = 0x0; $c = $c +| 0x1;'
> >>  >  Cannot unbox 65 bit wide bigint into native integer
> >>  >   in block  at -e line 1
> >>  >
> >>  > UInt uses magic Larry Wall powder to remove the constraints
> >>  > from the variable.  (Same powder he uses to create nils.)
> >>  >
> >>  >  p6 'my UInt $c = 0x0; $c = $c +|
> >>  > 0x1F; say
> >> $c'
> >>  >
> 862718293348820473429344482784628181556388621521298319395315527974911
> >>  >
> >>  > Other than the constrains, they act exactly the same.
> >>  > Oh, and they are both (generic programming term) unsigned
> integers
> >>  > (cardinals)
> >>  >
> >>  > :-)
> >>  >
> >>  > -T
> >>
> >>
> >> And good luck, all you who told me to read the
> >> documentation, trying to find the constraints
> >> explanation in the documentation:
> >>
> >> https://docs.raku.org/type/UInt
> >>
> >> Have fun!
> >>
> >> But it does say "The UInt is defined as a subset of Int:"
> >> and Int is definitely constrained.
> >>
>
> On 2020-01-13 19:13, Paul Procacci wrote:
> >  >> trying to find the constraints explanation in the documentation:
> >
> > https://docs.raku.org/language/nativetypes
> >
> > "Raku offers a set of /native/ types with a fixed, and known,
> > representation in memory"
> > and
> > "However, these types do not necessarily have the size that is required
> > by the NativeCall  interface
> > (e.g., Raku's |int| can be 8 bytes but C's |int| is only 4 bytes)"
> >
> > Took me all of 30 seconds to find.  Obviously that page has much more
> > information to offer than just those couple of sentences, but ALL native
> > types are constrained by a certain number of bits.
>
>
> Hi Paul,
>
> For those of you who were no privy to Paul and my
> offline discussion, he must have wrote me 10
> times trying to explain things to me before
> I got it.  He is a real mensch.
>
> 30 seconds!  Yikes!  I never found it.
>
> https://docs.raku.org/type/UInt
> should have stated that directly, but did not.
>
> And to add injury,
>
> https://docs.raku.org/language/nativetypes
>  "Raku offers a set of /native/ types with a fixed,
>  and known, representation in memory"
>
> Did not state who they were.  Sort of like when I
> want the  salt, I always reach for the pepper!
>
> The state of the documentation drives me  ...
>
>  AAHH! 
>
> -T
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users
On Mon, Jan 13, 2020 at 9:51 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:
 > On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:
 >> And, no one is telling me percisely what the difference
 >> between UInt and uint is other than one is a subset of
 >> Int and the other is a native type.  They act exactly
 >> the same.
 >
 > Hi All,
 >
 > Off line, Paul told me what the difference is
 > between a UInt and a uint.
 >
 > uint is constrained:
 >
 >  p6 'my uint $c = 0x0; $c = $c +| 0x1;'
 >  Cannot unbox 65 bit wide bigint into native integer
 >   in block  at -e line 1
 >
 > UInt uses magic Larry Wall powder to remove the constraints
 > from the variable.  (Same powder he uses to create nils.)
 >
 >  p6 'my UInt $c = 0x0; $c = $c +|
 > 0x1F; say
$c'
 > 862718293348820473429344482784628181556388621521298319395315527974911
 >
 > Other than the constrains, they act exactly the same.
 > Oh, and they are both (generic programming term) unsigned integers
 > (cardinals)
 >
 > :-)
 >
 > -T


And good luck, all you who told me to read the
documentation, trying to find the constraints
explanation in the documentation:

https://docs.raku.org/type/UInt

Have fun!

But it does say "The UInt is defined as a subset of Int:"
and Int is definitely constrained.



On 2020-01-13 19:13, Paul Procacci wrote:

 >> trying to find the constraints explanation in the documentation:

https://docs.raku.org/language/nativetypes

"Raku offers a set of /native/ types with a fixed, and known, 
representation in memory"

and
"However, these types do not necessarily have the size that is required 
by the NativeCall  interface 
(e.g., Raku's |int| can be 8 bytes but C's |int| is only 4 bytes)"


Took me all of 30 seconds to find.  Obviously that page has much more 
information to offer than just those couple of sentences, but ALL native 
types are constrained by a certain number of bits.



Hi Paul,

For those of you who were no privy to Paul and my
offline discussion, he must have wrote me 10
times trying to explain things to me before
I got it.  He is a real mensch.

30 seconds!  Yikes!  I never found it.

https://docs.raku.org/type/UInt
should have stated that directly, but did not.

And to add injury,

https://docs.raku.org/language/nativetypes
"Raku offers a set of /native/ types with a fixed,
and known, representation in memory"

Did not state who they were.  Sort of like when I
want the  salt, I always reach for the pepper!

The state of the documentation drives me  ...

 AAHH! 

-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Paul Procacci
 >> trying to find the constraints explanation in the documentation:

https://docs.raku.org/language/nativetypes

"Raku offers a set of *native* types with a fixed, and known,
representation in memory"
and
"However, these types do not necessarily have the size that is required by
the NativeCall  interface (e.g.,
Raku's int can be 8 bytes but C's int is only 4 bytes)"

Took me all of 30 seconds to find.  Obviously that page has much more
information to offer than just those couple of sentences, but ALL native
types are constrained by a certain number of bits.

On Mon, Jan 13, 2020 at 9:51 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:
> > On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:
> >> And, no one is telling me percisely what the difference
> >> between UInt and uint is other than one is a subset of
> >> Int and the other is a native type.  They act exactly
> >> the same.
> >
> > Hi All,
> >
> > Off line, Paul told me what the difference is
> > between a UInt and a uint.
> >
> > uint is constrained:
> >
> >  p6 'my uint $c = 0x0; $c = $c +| 0x1;'
> >  Cannot unbox 65 bit wide bigint into native integer
> >   in block  at -e line 1
> >
> > UInt uses magic Larry Wall powder to remove the constraints
> > from the variable.  (Same powder he uses to create nils.)
> >
> >  p6 'my UInt $c = 0x0; $c = $c +|
> > 0x1F; say $c'
> > 862718293348820473429344482784628181556388621521298319395315527974911
> >
> > Other than the constrains, they act exactly the same.
> > Oh, and they are both (generic programming term) unsigned integers
> > (cardinals)
> >
> > :-)
> >
> > -T
>
>
> And good luck, all you who told me to read the
> documentation, trying to find the constraints
> explanation in the documentation:
>
> https://docs.raku.org/type/UInt
>
> Have fun!
>
> But it does say "The UInt is defined as a subset of Int:"
> and Int is definitely constrained.
>
>
>
> -T
>


-- 
__

:(){ :|:& };:


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:

On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:

And, no one is telling me percisely what the difference
between UInt and uint is other than one is a subset of
Int and the other is a native type.  They act exactly
the same.


Hi All,

Off line, Paul told me what the difference is
between a UInt and a uint.

uint is constrained:

     p6 'my uint $c = 0x0; $c = $c +| 0x1;'
     Cannot unbox 65 bit wide bigint into native integer
  in block  at -e line 1

UInt uses magic Larry Wall powder to remove the constraints
from the variable.  (Same powder he uses to create nils.)

     p6 'my UInt $c = 0x0; $c = $c +| 
0x1F; say $c'   
862718293348820473429344482784628181556388621521298319395315527974911


Other than the constrains, they act exactly the same.
Oh, and they are both (generic programming term) unsigned integers 
(cardinals)


:-)

-T



And good luck, all you who told me to read the
documentation, trying to find the constraints
explanation in the documentation:

https://docs.raku.org/type/UInt

Have fun!

But it does say "The UInt is defined as a subset of Int:"
and Int is definitely constrained.



-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:

And, no one is telling me percisely what the difference
between UInt and uint is other than one is a subset of
Int and the other is a native type.  They act exactly
the same.


Hi All,

Off line, Paul told me what the difference is
between a UInt and a uint.

uint is constrained:

p6 'my uint $c = 0x0; $c = $c +| 0x1;'
Cannot unbox 65 bit wide bigint into native integer
 in block  at -e line 1

UInt uses magic Larry Wall powder to remove the constraints
from the variable.  (Same powder he uses to create nils.)

p6 'my UInt $c = 0x0; $c = $c +| 
0x1F; say $c' 
  862718293348820473429344482784628181556388621521298319395315527974911


Other than the constrains, they act exactly the same.
Oh, and they are both (generic programming term) unsigned integers 
(cardinals)


:-)

-T


Autoboxing

2020-01-13 Thread ToddAndMargo via perl6-users

Hi All,

https://docs.raku.org/language/numerics#Auto-boxing
https://docs.raku.org/language/nativetypes#Types_with_native_representation_and_size

I think I have uncovered a misunderstanding on my part.

I use to believe if you did not tell a variable
what its size was, that it was figured out on
the fly based on what you fed it.

Now I do believe that it takes on the size of the
largest available on the system and supported by
the language.

In other words, on a 64 bit system, an "int" would
be an "int64".

Am I finally correct?

Many thanks,
-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 16:58, The Sidhekin wrote:
On Tue, Jan 14, 2020 at 1:25 AM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2020-01-13 15:16, Laurent Rosenfeld via perl6-users wrote:
 > The way you consistently mixed up uint and Uint in the last hours,
 > despite having been warned about this mistake, also shows a lack of
 > proper consideration for the documentation.

Now that is a mystery to me.  The documentation for UInt
does not mention uint.   But UInt and uint act exactly
the same and have exactly the same properties.


   See, this is exactly what I'm talking about: "Documentation is easier 
to understand if you read what it says, and not what you expect it to say."


   Documentation does not say UInt and uint act exactly the same and 
have exactly the same properties.


   That's your expectation.

   Ignore your expectations.  Read what the documentation says, not what 
you expect it to say.


   It'll make more sense.


Eirik



Hi Eirik,

I can't find anything in the documentation other than native types for 
uint.  Do you have a link?  I would love one

of those flow charts where it shows what is a member of.

"Expectation"?  You mean experience.  And they act exactly
they way I expect them too.  UInt and uint act *exactly*
alike when I use them.

And, no one is telling me percisely what the difference
between UInt and uint is other than one is a subset of
Int and the other is a native type.  They act exactly
the same.  Tell where I am wrong?

-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread The Sidhekin
On Tue, Jan 14, 2020 at 1:25 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 15:16, Laurent Rosenfeld via perl6-users wrote:
> > The way you consistently mixed up uint and Uint in the last hours,
> > despite having been warned about this mistake, also shows a lack of
> > proper consideration for the documentation.
>
> Now that is a mystery to me.  The documentation for UInt
> does not mention uint.   But UInt and uint act exactly
> the same and have exactly the same properties.


  See, this is exactly what I'm talking about: "Documentation is easier to
understand if you read what it says, and not what you expect it to say."

  Documentation does not say UInt and uint act exactly the same and have
exactly the same properties.

  That's your expectation.

  Ignore your expectations.  Read what the documentation says, not what you
expect it to say.

  It'll make more sense.


Eirik


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 15:16, Laurent Rosenfeld via perl6-users wrote:
Your own record over the last years shows that you very often don't 
understand documentation (and I actually sometimes wonder whether you're 
even really interested in trying to understand it).


Actually, I go there a lot and I tear my hair out.
They are the antithesis of how Perl 5 wrote their
documentation (the only part of Perl 5 I like better
than Perl 6).

Your disdain for the documentation just confirms that. 


The documentation needs work.  Several involved in
the documentation process have mentioned this in
several places.  It is not like it is a secret.
I have tried to contribute to it before, but I
can't get past JJ.

And why do you think I am constantly find errors
in the documentation.  Because I ignore them?

By the way, "C String" REQUIRES a nul at the end:
an error in the NativeCall documentation.


But since you 
also explained very clearly times and again in the past that you don't 
want to read books or tutorials either, I also wonder whether you're 
interested in learning the language. I mean, *really* interested, to the 
point of making *real* efforts in that direction.


You have no idea what I go through.  You will if
you ever get to see my paper on NativeCall and
Win API.


The way you consistently mixed up uint and Uint in the last hours, 
despite having been warned about this mistake, also shows a lack of 
proper consideration for the documentation.


Now that is a mystery to me.  The documentation for UInt
does not mention uint.   But UInt and uint act exactly
the same and have exactly the same properties.  But
somehow they are different.  Since you know more than
I about Raku, please teach me the different.

Maybe I presume too much thinking this is yet another
error/oversight in the documentation.  Neither UInt
or uint even show up on

https://docs.raku.org/images/type-graph-Numeric.svg




The way you obstinately use the word  "cardinal" these last days also 
shows it, since there is simply no such thing as cardinals in the Raku 
types, subsets, or whatever, and, even though some languages have used 
it in the past (and, yes, I have also used Modula-2 in a quite distant 
past), "cardinal" is certainly NOT a common IT concept (I mean in the 
way integer, unsigned integer, or float are common concepts, often 
defined by CPU manufacturers). Granted, most people here probably have a 
good understanding of the word "cardinal," but it's essentially a math 
concept, and has no precise definition in a programming language, unless 
of course the programming language in question does define it, which 
Raku doesn't. Yes, cardinals may be loosely described as integers equal 
to or larger than zero, but that doesn't make a definition and that 
tells us nothing about their range or maximal value, or about the 
methods that can be invoked on them, and so on.


"cardinal" is a generic arithmetic and programming term.
It does not denote how many bit or bytes or whose CPU
calls what.  And it is only uncommon if you have not
heard it before.  And with your programming experience,
you should know the difference between generic
programming terms and language specific terms.

So, please, stop using the word "cardinal,", which is just improper, 
useless and essentially meaningless in the context of thee Raku 
language. Please use the types, subsets and other concept properly 
defined in Raku.


Look at what I write closely.  When I use a generic term like cardinal, 
I always put the Raku term in parenthesis.  If

this is not understandable to others, then it is a technical
writing issue on my part, not an ignorance of the
specifics any programming language.

I have been doing a lot with NativeCall and WinAPI
functions the last several weeks, so I have been
using a lot of generic terms and have had to learn C++
terms the hard way and how they map to Raku types.
(This is all in my paper.)  NativeCalls documentation
is almost, but not completely, useless.

By the way DWORD is a form of cardinal and are best
emulated as uint16.  You run into trouble with int16.
Did you notice that I said "form of a"?

I do the same thing with the generic term "Pointer", which
by the way can mean a lot of things.  Not all pointers
are C Pointers, such as Perl 5's "references", which is
what the parenthesis are for.  So when you use the term
"Pointer" you have to say what kind of pointer your
are talking about.

This conversation reminds me of one I had with the Perl 5
folks.  I prefer to call hashes, "associative arrays".
I got told how ignorant I was and how much I did not
understand the Perl.  A quote from Larry himself
ended that: he piked "hash" because it was easier to
write (fewer letters).



Sorry, I really don't mean to be blunt, but you should try harder to 
learn from what knowledgeable people tell you. Most of those who 
answered you know better.


Regards,
Laurent.



Many thanks,
-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Laurent Rosenfeld via perl6-users
> What makes you think I did not understand the documentation?

Your own record over the last years shows that you very often don't
understand documentation (and I actually sometimes wonder whether you're
even really interested in trying to understand it).

Your disdain for the documentation just confirms that. But since you also
explained very clearly times and again in the past that you don't want to
read books or tutorials either, I also wonder whether you're interested in
learning the language. I mean, *really* interested, to the point of making
*real* efforts in that direction.

The way you consistently mixed up uint and Uint in the last hours, despite
having been warned about this mistake, also shows a lack of proper
consideration for the documentation.

The way you obstinately use the word  "cardinal" these last days also shows
it, since there is simply no such thing as cardinals in the Raku types,
subsets, or whatever, and, even though some languages have used it in the
past (and, yes, I have also used Modula-2 in a quite distant past),
"cardinal" is certainly NOT a common IT concept (I mean in the way integer,
unsigned integer, or float are common concepts, often defined by CPU
manufacturers). Granted, most people here probably have a good
understanding of the word "cardinal," but it's essentially a math concept,
and has no precise definition in a programming language, unless of course
the programming language in question does define it, which Raku doesn't.
Yes, cardinals may be loosely described as integers equal to or larger than
zero, but that doesn't make a definition and that tells us nothing about
their range or maximal value, or about the methods that can be invoked on
them, and so on.

So, please, stop using the word "cardinal,", which is just improper,
useless and essentially meaningless in the context of thee Raku language.
Please use the types, subsets and other concept properly defined in Raku.

Sorry, I really don't mean to be blunt, but you should try harder to learn
from what knowledgeable people tell you. Most of those who answered you
know better.

Regards,
Laurent.


Le lun. 13 janv. 2020 à 22:45, ToddAndMargo via perl6-users <
perl6-users@perl.org> a écrit :

> On 2020-01-13 12:43, The Sidhekin wrote:
>
>
>
> On Mon, Jan 13, 2020 at 8:51 PM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> On 2020-01-13 11:10, ToddAndMargo via perl6-users wrote:
>> >
>> > https://docs.raku.org/type/UInt
>> > Subset UInt
>> > Unsigned integer (arbitrary-precision)
>> > The UInt is defined as a subset of Int:
>> > my subset UInt of Int where {not .defined or $_ >= 0};
>> > Consequently, it cannot be instantiated or subclassed;
>> > however, that shouldn't affect most normal uses
>>
>> Trivia:
>>
>> In https://docs.raku.org/type/UInt, a cardinal (uint)
>> is a subset
>>
>
>   Nope.  Case matters.  It's mixed case "UInt" (not "uint") that's a
> subset.
>
>
> Absolutely!  uint belongs to UInt
>
>
>
>> In https://docs.raku.org/language/nativetypes, a
>> cardinal (unit) gets their own "native type".
>>
>
>   … whereas (lower case) "uint" is a native type.
>
>   Documentation is easier to understand if you read what it says, and not
> what you expect it to say.
>
>
> Eirik
>
>
> Hi Erik,
>
> "uint" belongs to "UInt".  The error message should tell me one
> of the other.  I prefer "unit", but will compromise on "UInt".
> The ONLY beef I have is with the error message.
>
> What makes you think I did not understand the documentation?
> Perhaps it is you who does not understand me?
>
> Oh this is interesting:
> https://docs.perl6.org/type/UInt  (the raku one is missing the graphic)
>
> "The UInt is defined as a subset of Int:" but does not show on
> the graph.
>
> UInt --> Any --> Mu , but no "Int"
>
> Perhaps better stated would be
> UInt --> Int --> Any --> Numeric --> Mu
>
> I may have Mu and Numeric reversed
>
>
>
> Documentation is a thankless task  and those that do
> it are never appreciated.
>
> -T
>
>
>
>
>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>
>


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

  
  
On 2020-01-13 14:22, The Sidhekin
  wrote:


  Your use of the term "uint" in reference
to "UInt" is what makes me think so.
  
  
    uint and UInt are different types –
conceptually related, but with no type relation between them –
the document on UInt tells you nothing about uint.


You are correct there

https://docs.raku.org/type/UInt

does not use the term "uint". But the examples go on to use UInt as
a
uint. H. Maybe the documentation needs a little polish.
UInt and uint have the exact same properties.


  
  
    So when you say "a cardinal (uint) is a
subset", this is not taken from the cited documentation, and
appears to be taken from your own misapprehension.
  
  
  


Neither UInt or unit appears on the chart:
https://docs.raku.org/images/type-graph-Numeric.svg



And I have noticed that a lot of folks have taken my use of the
generic
arithmetic and programming term of cardinal way out of context.

-T
  



Re: Bug to report: cardinal called an integer

2020-01-13 Thread The Sidhekin
On Mon, Jan 13, 2020 at 10:46 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 12:43, The Sidhekin wrote:
>
> On Mon, Jan 13, 2020 at 8:51 PM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> In https://docs.raku.org/type/UInt, a cardinal (uint)
>> is a subset
>>
>
>   Nope.  Case matters.  It's mixed case "UInt" (not "uint") that's a
> subset.
>
>
> What makes you think I did not understand the documentation?
> Perhaps it is you who does not understand me?
>

  Your use of the term "uint" in reference to "UInt" is what makes me think
so.

  uint and UInt are different types – conceptually related, but with no
type relation between them – the document on UInt tells you nothing about
uint.

  So when you say "a cardinal (uint) is a subset", this is not taken from
the cited documentation, and appears to be taken from your own
misapprehension.


Eirik


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

  
  
On 2020-01-13 12:43, The Sidhekin
  wrote:


  
  




  On Mon, Jan 13, 2020 at 8:51
PM ToddAndMargo via perl6-users 
wrote:
  
  On 2020-01-13 11:10,
ToddAndMargo via perl6-users wrote:
> 
> https://docs.raku.org/type/UInt
>     Subset UInt
>     Unsigned integer (arbitrary-precision)
>     The UInt is defined as a subset of Int:
> 
   my subset UInt of Int where {not .defined or $_ >= 0};
> 
   Consequently, it cannot be instantiated or subclassed;
>     however, that shouldn't affect most normal uses

Trivia:

In https://docs.raku.org/type/UInt,
a cardinal (uint)
is a subset
  
  
  
    Nope.  Case matters.  It's mixed case "UInt" (not
"uint") that's a subset.
  

  


Absolutely!  uint belongs to UInt


  

   
  
In https://docs.raku.org/language/nativetypes,
a
cardinal (unit) gets their own "native type".
  
  
  
    … whereas (lower case) "uint" is a native type.
  
  
    Documentation is easier to understand if you read what
it says, and not what you expect it to say.
  
  
  
  
  
  Eirik
  

  


Hi Erik,

"uint" belongs to "UInt".  The error message should tell me one
of the other.  I prefer "unit", but will compromise on "UInt".
The ONLY beef I have is with the error message.

What makes you think I did not understand the documentation?
Perhaps it is you who does not understand me?  

Oh this is interesting:
https://docs.perl6.org/type/UInt  (the raku one is missing the
graphic)

"The UInt is defined as a subset of Int:"
but does not show on 
the graph.

UInt --> Any --> Mu , but no "Int"

Perhaps better stated would be
UInt --> Int --> Any --> Numeric --> Mu

I may have Mu and Numeric reversed



Documentation is a thankless task  and those that do
it are never appreciated.

-T







-- 
~~
Computers are like air conditioners.
They malfunction when you open windows
~~
  



Bug in the documentation

2020-01-13 Thread ToddAndMargo via perl6-users

Hi All,

https://docs.raku.org/type/UInt

Type Graph
Type relations for 404

The chart is 404 missing

To fix this, Raku can use the chart from
https://docs.perl6.org/type/UInt
https://docs.perl6.org/images/type-graph-UInt.svg

Picky, Picky, Picky

:-)

-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 12:56, Brad Gilbert wrote:

Ok looking into it, zero is inside of the set of cardinal numbers.

It is still wrong to call a uint a cardinal number.
It's just wrong for a different reason.

Looking through various definitions, a cardinal number is a number which 
represents a count of sets.


"count of sets" is going to far with the definition.  "Counting
number" is all a cardinal /unsigned integer is.



So a uint could be used to represent a cardinal number, but it could 
just as easily be a number that represents something other than a count.


If it is being used to index into a list it would be an ordinal number. 
(And so definitely not a cardinal number.)


Calling them cardinal numbers would imply something about them that may 
or may not be true.


The same would apply to calling it an unsigned integer.  You
are drilling down too far.



If it is being used to store a bitmask, then it would be wrong to call 
it a cardinal, ordinal, or even a natural number.


How so?  It is a collection of bits that counting numbers.

And you'd want to use a cardinal in a bit mask as the high
bit is not hijacked for the sign.

It may also be wrong to call it an integer, but at least that is what 
CPU designers call it.




Hi Brad,

When I use the term "cardinal" I am using the generic
arithmetic and programming term.  We call it a "uint"
is Raku.  Each computer language has it own set of
requirements and limitations for such.  I mean nothing
more or nothing less.

My only beef is with the error message.  I would like
the message changed to more accuracy reflect the
issue:

   This type cannot unbox to a native integer
to
   This type cannot unbox to subset UInt

or really pushing it:

   This type cannot unbox to native unsigned integer

The error is that athe variable is not a "native
integer", it is a native "unsigned integer".  This is
clearly stated at:

https://docs.raku.org/language/nativetypes

int   Equivalent to Int (with limited range)

uint  Equivalent to Int (with limited range) with
  the unsigned trait


-T


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Brad Gilbert
Ok looking into it, zero is inside of the set of cardinal numbers.

It is still wrong to call a uint a cardinal number.
It's just wrong for a different reason.

Looking through various definitions, a cardinal number is a number which
represents a count of sets.

So a uint could be used to represent a cardinal number, but it could just
as easily be a number that represents something other than a count.

If it is being used to index into a list it would be an ordinal number.
(And so definitely not a cardinal number.)

Calling them cardinal numbers would imply something about them that may or
may not be true.

If it is being used to store a bitmask, then it would be wrong to call it a
cardinal, ordinal, or even a natural number.

It may also be wrong to call it an integer, but at least that is what CPU
designers call it.


On Mon, Jan 13, 2020 at 1:51 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 11:10, ToddAndMargo via perl6-users wrote:
> >
> > https://docs.raku.org/type/UInt
> > Subset UInt
> > Unsigned integer (arbitrary-precision)
> > The UInt is defined as a subset of Int:
> > my subset UInt of Int where {not .defined or $_ >= 0};
> > Consequently, it cannot be instantiated or subclassed;
> > however, that shouldn't affect most normal uses
>
> Trivia:
>
> In https://docs.raku.org/type/UInt, a cardinal (uint)
> is a subset
>
> In https://docs.raku.org/language/nativetypes, a
> cardinal (unit) gets their own "native type".
>
> Life in the documentation lane!
>
> :-)
>


Re: Bug to report: cardinal called an integer

2020-01-13 Thread The Sidhekin
On Mon, Jan 13, 2020 at 8:51 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 11:10, ToddAndMargo via perl6-users wrote:
> >
> > https://docs.raku.org/type/UInt
> > Subset UInt
> > Unsigned integer (arbitrary-precision)
> > The UInt is defined as a subset of Int:
> > my subset UInt of Int where {not .defined or $_ >= 0};
> > Consequently, it cannot be instantiated or subclassed;
> > however, that shouldn't affect most normal uses
>
> Trivia:
>
> In https://docs.raku.org/type/UInt, a cardinal (uint)
> is a subset
>

  Nope.  Case matters.  It's mixed case "UInt" (not "uint") that's a subset.


> In https://docs.raku.org/language/nativetypes, a
> cardinal (unit) gets their own "native type".
>

  … whereas (lower case) "uint" is a native type.

  Documentation is easier to understand if you read what it says, and not
what you expect it to say.


Eirik


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 11:10, ToddAndMargo via perl6-users wrote:


https://docs.raku.org/type/UInt
    Subset UInt
    Unsigned integer (arbitrary-precision)
    The UInt is defined as a subset of Int:
    my subset UInt of Int where {not .defined or $_ >= 0};
    Consequently, it cannot be instantiated or subclassed;
    however, that shouldn't affect most normal uses


Trivia:

In https://docs.raku.org/type/UInt, a cardinal (uint)
is a subset

In https://docs.raku.org/language/nativetypes, a
cardinal (unit) gets their own "native type".

Life in the documentation lane!

:-)


Re: Bug to report: cardinal called an integer

2020-01-13 Thread ToddAndMargo via perl6-users

On 2020-01-13 06:17, Brad Gilbert wrote:

According to the description you copied, a cardinal can never be zero.

     any of the numbers
     that express amount, as one, two, three, etc.

So it is more accurate to call it an integer.


Hi Brad,

Are you referring to "any of the numbers that express
amount, as one, two, three, etc."?  Zero and twelve
for that matter are covered by both the "Counting"
part and the "etc." part.  And by the way, I don't
care if you call them cardinals, unsigned integers,
counting numbers, or whatever are long as the
description is correct,

A "Counting Number" starts at zero.  It just can't
be a fraction or less than zero.

I think what is happening here is the way Raku declares
their Roles, Classes, Types, and Subsets:

https://docs.raku.org/type/Real
role Real
   Non-complex number
   role Real does Numeric { ... }
   Common role for non-Complex numbers.


https://docs.raku.org/type/Int
   class Int
   Integer (arbitrary-precision)
   class Int is Cool does Real { }
   Int objects store integral numbers of arbitrary size. Ints are 
immutable.



https://docs.raku.org/type/UInt
   Subset UInt
   Unsigned integer (arbitrary-precision)
   The UInt is defined as a subset of Int:
   my subset UInt of Int where {not .defined or $_ >= 0};
   Consequently, it cannot be instantiated or subclassed;
   however, that shouldn't affect most normal uses

This would make the cardinal type of UInt an "Int"
with "Restrictions".  It also frees the high bit
for usage in the number.

This perfectly follows:
https://www.mathopenref.com/cardinal.html
   Cardinal numbers (also called whole numbers, natural
   numbers, or counting numbers) are those used to count
   physical objects in the real world, such as

  0, 1, 2, 3, 4 .

   They are integers that can be zero or positive. They
   assume that the things being counted are not divisible.
   So we can have 4 cars, but never 3½ cars.

   Formally, counting numbers are the set of all
   non-negative integers.

   Cardinal numbers are also called counting numbers.
   ["$_ >= 0" from Raku]


So is Raku, a cardinal, called UInt in Raku, is a "subset
of Int" and a member of Int who is a member of Real.

No problem with any of that.  My ONLY problem is with the
error message.

What would make me happy would be if the error message
was changed from:

   This type cannot unbox to a native integer
to
   This type cannot unbox to subset UInt

-T


Now if we really, really wanted to make this thread annoying,
we would question why does Int belongs to Real:

https://www.mathopenref.com/real-number.html

  A real number is a value that represents any quantity
  along a number line. Because they lie on a number
  line, their size can be compared. You can say one
  is greater or less than another, and do arithmetic
  with them.

In other words, they can be fractions.  Integers can not.
But I am not going down that road.  Raku has it all perfectly
figured out.

And Real has a nice error message:
$ p6 'my Real $r; $r = "XYZ";'
Type check failed in assignment to $r; expected Real
but got Str ("XYZ") in block  at -e line 1


Re: weirdness with subset on has

2020-01-13 Thread Joseph Brenner
Okay, I opened a github issue:

  https://github.com/rakudo/rakudo/issues/3421



On 1/13/20, Vadim Belman  wrote:
> At a quick glance, looks like a bug to me. Worth opening a ticket on
> https://github.com/rakudo/rakudo
>
> Best regards,
> Vadim Belman
>
>> On Jan 12, 2020, at 8:15 PM, Joseph Brenner  wrote:
>>
>> Moving the definition of the subset outside of the class
>> covers for the weird behavior...
>>
>>  my @allowed = << alpha beta gamma delta >>;
>>  my @default = << alpha >>;
>>  subset Allowed of Str where * eq any( @allowed );
>>
>>  class HasSubset {
>>  has Allowed @.grk = @default;
>>  method echo_grk {
>>  say @!grk.join(" | ");
>>  }
>>  }
>>
>>  my $obj = HasSubset.new();
>>  $obj.echo_grk();
>>
>>  my $obj2 = HasSubset.new( grk => << alpha beta gamma >> );
>>  $obj2.echo_grk();
>>
>>  my $obj3 = HasSubset.new( grk => << alpha beta rutabaga >> );
>>  $obj3.echo_grk();
>>  # value 'rutabaga' fails as expected:
>>  # Type check failed in assignment to @!grk; expected
>> HasSubset::Allowed but got Str ("rutabaga")
>>
>>
>> On 1/12/20, Joseph Brenner  wrote:
>>> Here's a code snippet that tries to use a subset to constrain the
>>> values of an object field (i.e. declared with has).  As written, this
>>> code works, but only when there's what looks like an irrelevant
>>> experimental line in it (labeled "WEIRD ONE"), when that line is
>>> commented out it throws an error...
>>>
>>>  class HasSubset {
>>>  my @allowed = << alpha beta gamma delta >>;
>>>  my @default = << alpha >>;
>>>
>>>  subset Allowed of Str where * eq any( @allowed );
>>>
>>>  my Allowed $experiment = 'delta'; # WEIRD ONE this line is
>>> *needed* to get the following to work...
>>>
>>>  has Allowed @.greek = @default;
>>>
>>>  method echo_greek {
>>>  say @!greek.join(" | ");
>>>  }
>>>  }
>>>
>>>  my $obj = HasSubset.new();
>>>  $obj.echo_greek();
>>>
>>>  # As written, prints the default: 'alpha'
>>>  # Without the WEIRD ONE line, you see errors like:
>>>  ## Type check failed in assignment to @!greek; expected
>>> HasSubset::Allowed but got Str ("alpha")
>>>
>>
>
>


Re: weirdness with subset on has

2020-01-13 Thread Vadim Belman
At a quick glance, looks like a bug to me. Worth opening a ticket on 
https://github.com/rakudo/rakudo

Best regards,
Vadim Belman

> On Jan 12, 2020, at 8:15 PM, Joseph Brenner  wrote:
> 
> Moving the definition of the subset outside of the class
> covers for the weird behavior...
> 
>  my @allowed = << alpha beta gamma delta >>;
>  my @default = << alpha >>;
>  subset Allowed of Str where * eq any( @allowed );
> 
>  class HasSubset {
>  has Allowed @.grk = @default;
>  method echo_grk {
>  say @!grk.join(" | ");
>  }
>  }
> 
>  my $obj = HasSubset.new();
>  $obj.echo_grk();
> 
>  my $obj2 = HasSubset.new( grk => << alpha beta gamma >> );
>  $obj2.echo_grk();
> 
>  my $obj3 = HasSubset.new( grk => << alpha beta rutabaga >> );
>  $obj3.echo_grk();
>  # value 'rutabaga' fails as expected:
>  # Type check failed in assignment to @!grk; expected
> HasSubset::Allowed but got Str ("rutabaga")
> 
> 
> On 1/12/20, Joseph Brenner  wrote:
>> Here's a code snippet that tries to use a subset to constrain the
>> values of an object field (i.e. declared with has).  As written, this
>> code works, but only when there's what looks like an irrelevant
>> experimental line in it (labeled "WEIRD ONE"), when that line is
>> commented out it throws an error...
>> 
>>  class HasSubset {
>>  my @allowed = << alpha beta gamma delta >>;
>>  my @default = << alpha >>;
>> 
>>  subset Allowed of Str where * eq any( @allowed );
>> 
>>  my Allowed $experiment = 'delta'; # WEIRD ONE this line is
>> *needed* to get the following to work...
>> 
>>  has Allowed @.greek = @default;
>> 
>>  method echo_greek {
>>  say @!greek.join(" | ");
>>  }
>>  }
>> 
>>  my $obj = HasSubset.new();
>>  $obj.echo_greek();
>> 
>>  # As written, prints the default: 'alpha'
>>  # Without the WEIRD ONE line, you see errors like:
>>  ## Type check failed in assignment to @!greek; expected
>> HasSubset::Allowed but got Str ("alpha")
>> 
> 


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Brad Gilbert
According to the description you copied, a cardinal can never be zero.

any of the numbers
that express amount, as one, two, three, etc.

So it is more accurate to call it an integer.

On Mon, Jan 13, 2020 at 1:32 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-12 20:03, Darren Duncan wrote:
> > On 2020-01-09 10:10 a.m., ToddAndMargo via perl6-users wrote:
> >> A bug to report:
> >>
> >> $ p6 'my uint32 $c; $c = "ABC";'
> >> This type cannot unbox to a native integer: P6opaque, Str
> >>in block  at -e line 1
> >>
> >> "uint32" is not an "integer".  It is a cardinal.  If
> >> they really want to use the word "integer" for cardinal,
> >> they should change the wording to "unsigned integer".
> >>
> >> Picky, picky, picky
> >
> > ToddAndMargo, you are wrong on this.
> >
> > A uint32 is NOT specifically a cardinal.
>
> Hi Darren,
>
> Since a uint32 ca not be negative or a fraction,
> it is a cardinal.  Other operating system do call
> them cardinals, such as Modula2. Pascal, C++ (I
> think C too), Java, and so on and so forth.
>
> > At best you can say it can be characterized by a cardinal or be
> > isomorphic to one.
>
> https://www.dictionary.com/browse/isomorphism
> isomorphism
>  noun
>  Mathematics. a one-to-one relation onto the map
>  between two sets, which preserves the relations
>  existing between elements in its domain.
>
> I am not following what you are getting at.
>
> > A uint32 is just as much an ordinal as a cardinal, so insisting on
> > calling it a cardinal means the type can't be used as an ordinal, or a
> > variety of other things.
>
> https://www.dictionary.com/browse/ordinal-number
> ordinal number
> noun
> Also called ordinal numeral. any of the numbers that
> express degree, quality, or position in a series, as
> first, second, and third *(distinguished from cardinal
> number)*.
>
> Mathematics. a symbol denoting both the cardinal number
> and the ordering of a given set, being identical for
> two ordered sets having elements that can be placed
> into one-to-one correspondence, the correspondence
> preserving the order of the elements.
>
> https://www.dictionary.com/browse/cardinal-number
> cardinal number
> noun
> Also called cardinal numeral. any of the numbers
> that express amount, as one, two, three, etc.
> *(distinguished from ordinal number)*.
>
> No idea how you are mixing these two.  I can see
> how yo would use a cardinal in programming to
> denote an ordinal, if that is what you are getting at.
>
>
> > Calling this an unsigned integer (u int) is much more accurate as it
> > doesn't presume a particular semantics such as that we are storing a
> > count rather than a position for example, it says what we actually know,
> > and no more.
>
> I am sorry, I have no idea what you are trying to say.  I do not care if
> you call a cardinal an unsigned integer.  Just
> don't call it an integer.  The high bit in a cardinal is
> part of the number and denotes a negative number in an integer.
>
> >
> > You are also wrong on saying that the values one can store in a uint32
> > are not integers; they definitely ARE integers.  Every cardinal is an
> > integer.
>
> Where do you get that.  A cardinal can not be negative.  An
> Integer can.  And the structure is even different:  the high
> bit in an integer denote the sign of the integer; the high bit
> in a cardinal is just a higher positive number.  So they
> are not the same by any shake.
>
>
> > If you want to be precise, calling a uint32 an "unsigned integer" or
> > "cardinal" is inaccurate in the same way that calling it an "integer"
> > is.
>
> Perfectly accurate.  Unsigned integer and a cardinal are
> exactly the same thing.   The only difference is the
> amount of letter you need to use to describe them.
> Sort of like "associative array" and "hash"
>
> > In either case, the variable can only hold a proper subset of
> > either type, not all of them.  If you're calling integer wrong then one
> > will have to call the type something like "integers in the range
> > 0..^2**32".
> >
> > -- Darren Duncan
>
> The difference between a cardinal and an integer is
> the high bit.  Both are whole numbers.  An integer
> can be negative.  A cardinal can not.
>
> If you are going to error out something, say the proper
> variable type you are error out on.  Cardinal or unsigned
> integer, I don't care which you call a cardinal.  Whatever
> floats your boat.  Both descriptions are correct.  Just
> be correct.
>
> -T
>
> p.s. in assembly, they call a cardinal an unsigned integer.
>


Fw: [perl-foundation-outreach] Applications open tomorrow

2020-01-13 Thread Patrick Spek via perl6-users
Anyone with ideas for the Google Summer of Code, please share them! If
you don't have a GitHub account (or don't want to do the effort of
getting a PR merged), you can share them on the ML or in private mail,
and I'll do my best to get them on the GitHub repository.

Begin forwarded message:

On Mon, 13 Jan 2020 00:39:11 -0800 (PST)
JJ Merelo  wrote:

> So we really need to get this going.
> 
> You can send ideas via pull request 
> https://github.com/perl-foundation-outreach/gsoc-2020-ideas or
> discuss them in issues, same as last year. We need at least 10-15
> different project ideas students can engage with.
> 
> JJ

-- 
With kind regards,

Patrick Spek


www:  https://www.tyil.nl/
mail: p.s...@tyil.nl
pgp:  1660 F6A2 DFA7 5347 322A  4DC0 7A6A C285 E2D9 8827

social: https://soc.fglt.nl/tyil
git:https://gitlab.com/tyil/


pgpzI2lxZpQu_.pgp
Description: OpenPGP digital signature


Re: rakudo.org outdated?

2020-01-13 Thread Patrick Spek via perl6-users
On Sun, 12 Jan 2020 13:59:43 -0800
yary  wrote:

> I downloaded the Rakudo Star 2019.11-rc1 source installer from
> https://dist.tyil.nl/raku/rakudo-star/ and built it on OS X 10.15.2
> "Catalina", rakudo-test complains about Native Call, and also that a
> couple TODO's pass
> 
> *Test Summary Report*
> t/04-nativecall/20-concurrent.t   (Wstat:
> 65280 Tests: 0 Failed: 0)
>   Non-zero exit status: 255
>   Parse errors: Bad plan.  You planned 3 tests but ran 0.
> t/09-moar/Line_Break__LineBreak.t (Wstat:
> 0 Tests: 2 Failed: 0)
>   TODO passed:   2
> t/09-moar/General_Category__extracted-DerivedGeneralCategory.t
> (Wstat: 0 Tests: 1 Failed: 0)
>   TODO passed:   1
> Files=103, Tests=1773, 84 wallclock secs ( 0.56 usr  0.22 sys +
> 247.48 cusr 24.06 csys = 272.32 CPU)
> Result: FAIL
> make[1]: *** [m-coretest5] Error 1
> make: *** [rakudo-test] Error 2
> 
> still "make install" got me a Raku that's good enough for me to keep
> tinkering with
> 
> -y

Thanks Yary!

I'm glad it works for you without too much troubles. I'm unsure what
exactly goes wrong with the NativeCall stuff, nor what might be
affected by it.

Perhaps a Raku core dev can tell us more about this?

-- 
With kind regards,

Patrick Spek


www:  https://www.tyil.nl/
mail: p.s...@tyil.nl
pgp:  1660 F6A2 DFA7 5347 322A  4DC0 7A6A C285 E2D9 8827

social: https://soc.fglt.nl/tyil
git:https://gitlab.com/tyil/


pgpqhedikTEeS.pgp
Description: OpenPGP digital signature