Re: fixing infinities and ranges etc

2016-10-30 Thread Darren Duncan

On 2016-10-30 5:45 AM, yary wrote:

I'm not sure I entirely understand the proposal- does it change Inf aka ∞ ?


Part of the issue I think is that the existing "Inf" aka "∞" don't seem to be 
very clearly defined.


What I could find so far, at least with respect to Ranges, is that they are just 
syntactic alternatives to the Whatever *.


They don't seem to be actual typed values that one can say use as declared types 
for things.



Otherwise I like it, and prefer the X::NegInf and X::PosInf,spellings as being
easy-to-understand & a good Huffman-encoding.


Ok.


Before/AfterEverything are also easy to understand, and would be as natural to
use for sorting strings, eg. for saying if a database NULL should go before the
empty string or after everything else. On the other hand, if I'doing something
with tangents and handling pi/2, I'd rather be thinking about PosInf as my
exception and not AfterEverything.


So, the main thing that I think should exist is a generic 
before/after-everything concept so that it can be used to indicate that generic 
intervals are unbounded at either end and that generic 'cmp' etc are 
automatically defined for every other type and them and use as identity values 
for min/max.


At the same time, I think some people would want to distinguish between these 
and a mathematical concept of infinity in a similar manner that people 
distinguish orderable and ordered and ordinal etc.


What I mean by the latter is, "ordered" and "ordinal" have rather precise 
meanings in set theory or mathematics etc, meanings that don't apply to a lot of 
data types we tend to sort on.  For example, ordered/ordinal strictly speaking 
wouldn't apply to character strings and they may not apply consistently to the 
general case of rational numbers and so on; for some types we just want to be 
able to sort them deterministically but the actual sort order might not be 
meaningful within the domain.  So I made up the term "orderable" to refer to 
what generic "cmp" or SQL "order by" etc do.


The before/after-everything singleton are meant specifically to apply to this 
"orderable" concept.


So, having that, the question is whether we want to have distinct infinity 
concepts for numbers from those, and I suspect we might.  In maths we have 
directional infinities on a line, but there's also the concept of something 
being infinite that is not directional such as an unbounded volume, and there's 
also countable vs uncountable infinities etc.  We may not want to imply any of 
those with our before/after-everything concept which is meant to serve a 
different purpose.



X::BE and X::AE are too short to use outside of this discussion, especially as
"BE" is the common verb "be."


Maybe X::OBE and X::OAE for "ordered before/after everything"?

Anyway, this part is bike-shedding, my main point is that the singletons simply 
exist and what their properties are.



Before/AfterEverything ... would be as natural to
use for sorting strings, eg. for saying if a database NULL should go before the
empty string or after everything else.


So, now this brings up a different thing.

A Perl 6 analogy to a SQL Null would ALSO be a Failure singleton type, for 
example X::NoReason, basically it means that we don't have a normal value of the 
domain here AND we are giving absolutely no explanation for why the normal value 
is missing.  A SQL Null in general means means "we don't have a normal value and 
we aren't saying why", it does NOT mean "not applicable" or "unknown" or 
"missing" or "not matched" or anything like that, it doesn't even say which of 
those it is.


As far as I could tell the Perl 6 Nil singleton had this X::NoReason meaning, 
but if it actually doesn't, then we should have a new X::NoReason to be more 
explicit about that.  This would mean that a Perl 6 Nil actually IS giving a 
reason why the normal value is absent.


As a final note today, I will mention that the subject of this email thread is 
relevant to this thing that I'm working on, a DBI for Perl 6 with a PSGI/Plack 
inspired design, meaning a no-mandatory-shared-code database interface:


https://github.com/muldis/Muldis-DBI-Duck-Coupling-Perl6/blob/master/lib/Muldis/DBI/Duck_Coupling/API.pod

-- Darren Duncan



[perl #127306] type captures in return type is not resolved

2016-10-30 Thread Christian Bartolomaeus via RT
On Mon Jan 18 06:00:47 2016, gfldex wrote:
> sub foo(::T $t --> T){ T.new };
> my Int $i = 42;
> foo($i);
> 
> # OUTPUT«Type check failed for return value; expected T but got Int␤  in 
> # sub foo at /tmp/HqdmxVFmny line 1␤  in block  at /tmp/HqdmxVFmny 
> # line 1␤␤»

As a status update: This looks somewhat worse now:

$ ./perl6-m -e 'sub foo(::T $t --> T){ 45 }; my Int $i = 42; foo($i);'
X::TypeCheck::Return exception produced no message
  in sub foo at -e line 1
  in block  at -e line 1

$ ./perl6-m --version
This is Rakudo version 2016.10-104-gdb61aaa built on MoarVM version 
2016.10-27-g196361f
implementing Perl 6.c.


[perl #127059] Error with typed Array as attribute when trying to display the type.

2016-10-30 Thread Christian Bartolomaeus via RT
This works now:

$ $ perl6 -e 'class A {has Str $.n; has Str @.m}; for A.^attributes -> $attr 
{say $attr.name, $attr.type};'
$!n(Str)
@!m(Positional[Str])

It looks like the problem back then was related to using gist. I tried with an 
older rakudo:

$ $ ./perl6-m --version
This is Rakudo version 2015.12-60-g37e998d built on MoarVM version 2015.12
implementing Perl 6.c.

$ ./perl6-m -e 'class A {has Str @.array}; say A.^attributes[0].type.gist'
Method 'shortname' not found for invocant of class 
'Perl6::Metamodel::CurriedRoleHOW'
  in block  at -e line 1

$ ./perl6-m -e 'class A {has Str @.array}; say A.^attributes[0].type.perl'
Positional[Str]

I added a test to S12-introspection/attributes.t with commit 
https://github.com/perl6/roast/commit/b06e156032

I'm closing this ticket as 'resolved'.


[perl #123506] [JVM] List Comprehension assigned to capture variable is Nil

2016-10-30 Thread Christian Bartolomaeus via RT
This works now as expected:

$ ./perl6-j -e 'my \T = ($_ for ^1); say T'
(0)

§ ./perl6-j -e 'my \T = ($_ for ^2); say T'
(0 1)

$ ./perl6-j -e 'say ($_ for ^2)'
(0 1)

I added two tests to S04-statements/for.t with commit 
https://github.com/perl6/roast/commit/fc9a4a8523

I'm closing this ticket as 'resolved'.


Re: fixing infinities and ranges etc

2016-10-30 Thread yary
I'm not sure I entirely understand the proposal- does it change Inf aka ∞ ?

Otherwise I like it, and prefer the X::NegInf and X::PosInf,spellings as
being easy-to-understand & a good Huffman-encoding.

Before/AfterEverything are also easy to understand, and would be as natural
to use for sorting strings, eg. for saying if a database NULL should go
before the empty string or after everything else. On the other hand, if
I'doing something with tangents and handling pi/2, I'd rather be thinking
about PosInf as my exception and not AfterEverything.

X::BE and X::AE are too short to use outside of this discussion, especially
as "BE" is the common verb "be."