cannot create an instance of subset type

2020-07-10 Thread Marcel Timmerman

Hi,

Using the next code I get an error on the instantiation of $d2;

---
use v6;

class ABC {
  method s ( Int $i ) { say $i + 10; }
}

subset DEF of ABC;

my ABC $a .= new;
$a.s(10);   # 20

my DEF $d1 = $a;
$d1.s(11);  # 21

my DEF $d2 .= new;
$d2.s(12);
---

Error is

You cannot create an instance of this type (DEF)
  in block  at xt/subset-test.pl6 line 15

Why is this?

Regards,
Marcel


Re: cannot create an instance of subset type

2020-07-10 Thread Brad Gilbert
Subset types are not object types.

A subset is basically a bit of checking code and base type associated with
a new type name.

In something like:

my ABC $a .= new;

That is exactly the same as:

my ABC $a = ABC.new;

Well there is no functional `.new` method on any subset types, so
`DEF.new()` isn't going to do anything.

DEF.new # ERROR

---

The worst part of your code is that you are using a `subset` without a
`where` clause. Which is almost completely pointless.

I honestly think that there is an argument to be made that it shouldn't
even be possible to write a `subset` without a `where` clause.

It isn't like other languages where you can create something like a
lightweight clone or lightweight subclass of a type.
It also isn't an alias.

It's whole purpose is to attach a `where` clause as an extra check to type
based things.



If you want an alias, use an alias

my constant DEF = ABC;

my constant DEF = ABC:D;

If you want a lightweight subclass, create a lightweight subclass.

my class DEF is ABC {}

If you want an extra check, then and only then does it make sense to use a
`subset`.

my subset GHI of Int where -10 ≤ $_ ≤ 10;

---

A `subset` without a `where` clause only makes certain language features
become unavailable.
Unless that is exactly what you want to accomplish, use something else.

On Fri, Jul 10, 2020 at 3:18 PM Marcel Timmerman  wrote:

> Hi,
>
> Using the next code I get an error on the instantiation of $d2;
>
> ---
> use v6;
>
> class ABC {
>method s ( Int $i ) { say $i + 10; }
> }
>
> subset DEF of ABC;
>
> my ABC $a .= new;
> $a.s(10);   # 20
>
> my DEF $d1 = $a;
> $d1.s(11);  # 21
>
> my DEF $d2 .= new;
> $d2.s(12);
> ---
>
> Error is
>
> You cannot create an instance of this type (DEF)
>in block  at xt/subset-test.pl6 line 15
>
> Why is this?
>
> Regards,
> Marcel
>


Raku-LibCurl:ver<1.0> install error on older MacOS?

2020-07-10 Thread William Michels via perl6-users
Hello,

I just updated to Rakudo-2020.06, and while updating many of my
modules to their latest versions I saw an error installing/updating
(Raku) LibCurl. Below, the first few lines of the error seen with
LibCurl::Easy (and EasyHandle):

===> Testing: LibCurl:ver<1.0>:auth:api<1>
[LibCurl] # Failed test 'LibCurl::EasyHandle module can be use-d ok'
[LibCurl] # at t/01-load.t line 6
[LibCurl] # Cannot load native library 'libcurl.so.4'
[LibCurl] # Failed test 'LibCurl::Easy module can be use-d ok'
[LibCurl] # at t/01-load.t line 8
[LibCurl] # ===SORRY!=== Error while compiling
/Users/myuseraccount/.zef/store/raku-libcurl.git/random_40-character-alphanumeric/lib/LibCurl/Easy.rakumod
(LibCurl::Easy)
[LibCurl] # Cannot load native library 'libcurl.so.4'
[LibCurl] # at 
/Users/myuseraccount/.zef/store/raku-libcurl.git/random_40-character-alphanumeric/lib/LibCurl/Easy.rakumod
(LibCurl::Easy):2

So one caveat is that this install is on an OS which many would
consider to be "MacOS.10.ancient" [I'm posting here and not on Github
because we seem to have a number of Mac users on this mailing-list].
But the fact of the matter is Raku LibCurl:ver<0.9> worked just fine
with Rakudo-2020.02.1. Furthermore, now that I've downgraded back to
Raku LibCurl:ver<0.9>, LibCurl::Easy works once again on the latest
Rakudo-2020.06. So I really feel the problem is with LibCurl:ver<1.0>
on Macs, and not my particular install.

Questions for Mac-heads: Do newer versions of MacOS still install
LibCurl as part of the OS? Where does that reside? I know I have
libcurl in the following directories, however 'libcurl.so.4' is
conspicuously absent:

/opt/local/lib/libcurl.4.dylib
/opt/local/lib/libcurl.a
/opt/local/lib/libcurl.dylib

Are Mac-users able to use (Raku) LibCurl:ver<1.0> on their (newer)
systems? FYI, I've installed curl independently of MacOS via either
MacBrew or MacPorts, and in fact MacBrew reports upon attempting to
update: "Warning: curl 7.71.1 is already installed and up-to-date".

Any help appreciated, Thx, Bill.