Mailing List Archive

PPC Elevator Pitch for Perl::Types
# Proposed Perl Changes Elevator Pitch for Perl::Types

This document is the first step in the Proposed Perl Changes process:

https://github.com/Perl/PPCs/blob/main/README.md

Respectfully submitted by the _Perl::Types Committee_:
* Will Braswell (WBRASWELL), Co-Founder & Chairman
* Brett Estrade (OODLER), Co-Founder & 1st Vice Chairman
* Zakariyya Mughal (ZMUGHAL), Co-Founder & 2nd Vice Chairman
* John Napiorkowski (JJNAPIORK)
* Darren Duncan (DUNCAND)
* Nedzad Hrnjica (NHRNJICA)
* Rohit Manjrekar (MANJREKAR)
* Paul Millard (MAGUDAS)
* Joshua Day (HAX)
* Tyler Bird (BIRDTY)
* Robbie Hatley (HATLEYSFT)
* David Warner (WESTBASE)
* Daniel Mera (DMERA)
* Duong Vu (DVU)
* Rajan Shah (RSHAH)

## Here is a problem

Perl lacks sufficient exposure of the already-existing real natural
Perl data types for use by the programmer. This has lead to false
claims that the Perl interpreter "has no data types". This has
also lead to countless programmer-hours spent devising synthetic
or unnatural type systems that rely entirely on fuzzy data guessing
via regular expressions, etc.

Fortunately, the Perl compiler already provides the capability to
expose the underlying real native C data types which can be used
by Perl programmers to incrementally improve performance, eventually
achieving the full native speed of compiled C code. Among other
features, the Perl compiler also enables real natural data type
checking with identical behavior in both dynamic (intrepreted) mode
and static (compiled) mode.

https://metacpan.org/dist/RPerl

The data type subsystem of the Perl compiler is currently in the
process of being extracted and refactored as an independant CPAN
distribution called `Perl::Types`. This distribution provides new,
core capabilities and thus should be included in the Perl core
distribution as a "Dual-Life" module.

https://github.com/Dual-Life

## Here is the syntax that we're proposing

The Perl interpreter already has an unused slot in the grammar for
this very purpose:

`my TYPE $var;`

The Perl interpreter and the Perl compiler already provide the
basic data types to be used in the grammar slot above:

* `boolean` (`SV` when `SvIsBOOL(sv)` is true, new in 5.36)
* `integer` (`IV`)
* `number` (`NV`)
* `string` (`PV`)
* `array` (`AV`) & `arrayref` (`RV(AV)`)
* `hash` (`HV`) & `hashref` (`RV(HV)`)
* user-defined classes

Custom data structures are declared with compound or nested data
types composed from the basic types above, for example:

* `integer::arrayref`
* `integer::arrayref::arrayref`
* `integer::arrayref::hashref`
* `integer::arrayref::arrayref::hashref`
* `string::arrayref`
* `MyClass::arrayref`
* etc.

Attempting to utilize incompatible data types gives the same behavior
and same errors in both interpreted mode and compiled mode, for
example:

```
#!/usr/bin/perl
use Perl::Types;

sub squared {
{ my number $RETURN_TYPE };
( my number $base ) = @ARG;
return $base ** 2;
}

squared(2); # FINE
squared(2.3); # FINE
squared(to_number('2')); # FINE
my number $foo = 23;
squared($foo); # FINE

squared(); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value expected but ...
squared('2'); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value expected but ...
my string $bar = 'howdy';
squared($bar); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value expected but ...
squared([2]); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value expected but ...
```

The syntax for arrays and hashes is similarly straightforward:
```
sub multiply_array {
{ my number::arrayref $RETURN_TYPE };
( my integer $input_integer, my number::arrayref $input_array ) = @ARG;
my number::arrayref $output_array = [
$input_integer * $input_array->[0],
$input_integer * $input_array->[1],
$input_integer * $input_array->[2]
];
return $output_array;
}

sub multiply_hash {
{ my number::hashref $RETURN_TYPE };
( my integer $input_integer, my number::hashref $input_hash ) = @ARG;
my number::hashref $output_hash = {
a => $input_integer * $input_hash->{a},
b => $input_integer * $input_hash->{b},
c => $input_integer * $input_hash->{c}
};
return $output_hash;
}
```

## Here are the benefits of this

The primary benefit of including `Perl::Types` in the Perl core
distribution is that it will provide a greatly-needed capability
of exposing the underlying C-level data types and data structures
to every Perl programmer, so they may utilize Perl data types to
achieve a number of benefits including but not limited to:

* increased performance
* code correctness
* type safety (type checking)
* memory safety (bounds checking)
* documentation of code intent
* potential for polymorphism
* potential for derived or synthetic types

Additionally, this foundational support for enabling Perl data
types at the interpreter level will allow for the creation of
synthetic or unnatural data types and data structures to be built
on top of `Perl::Types` itself. For example, the capabilities
provided in `Perl::Types` are necessary for any effort to introduce
real natural type checking constraints related to Perl's new `class`
keyword.

## Here are potential problems

Because the Perl interpreter has already implemented both the real
natural Perl data types, as well as the required `my TYPE $var`
syntax construct, we therefore do not foresee the introduction of
any significant issues by including `Perl::Types` in the Perl core
distribution.

The largest barrier to adoption for the Perl compiler is the need
for numerous non-Perl dependencies, such as the C++ compiler and
other libraries. This barrier will be completely removed for the
`Perl::Types` distribution, due to being refactored out of the
compiler distribution and removal of all non-core dependencies.

On Behalf of the _Perl::Types Committee_,
Brett Estrade

--
oodler@cpan.org
oodler577@sdf-eu.org
SDF-EU Public Access UNIX System - http://sdfeu.org
irc.perl.org #openmp #pdl #native
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
Lot of such discussions were made in Oshun, so few notes:
- will it pollute global symbol space or will it have separated space?
- will it be available at runtime
- please reserve prefix syntax for alternate internal representation (eg:
ordered hashes, sparse arrays, ...)
- be modern - typical stack is SQL (postfix type), Perl, some openapi
(postifx type), some typescript (postfix type) - if you want attract new
programmers, don't burden them with additional habits, they need to focus
on their work
- be different - provide something that others do not (well, SQL does) -
declarative constraints
- how it will fit with classical Perl code bases written without this ?
- how it will improve readability of mixed usage? Is mixed usage even
allowed ?

Generally, what I'm missing is comparison with other popular languages, how
they solve problem
- some typical Perl app communicates with (eg as mentioned SQL + openapi +
typescript)
- some more popular languages: python, ruby, java, kotlin is imho minimum,
Rust, Go nice bonus
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, Aug 16, 2023 at 12:37?AM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:

> # Proposed Perl Changes Elevator Pitch for Perl::Types
>

...


> The data type subsystem of the Perl compiler is currently in the
> process of being extracted and refactored as an independant CPAN
> distribution called `Perl::Types`. This distribution provides new,
> core capabilities and thus should be included in the Perl core
> distribution as a "Dual-Life" module.
>

I'm not sure a PPC is necessary to propose a CPAN module to become dual
life. If the module is developed on CPAN, the only purpose of including it
in core is for it to ship with Perl; Perl core has no say in its design or
development on CPAN. Though I will say that there is not a formal process
for deciding which modules to ship with core currently and that is
something that could use improvement.

-Dan
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
Hi there,

On Wed, 16 Aug 2023, Oodler 577 via perl5-porters wrote:

> # Proposed Perl Changes Elevator Pitch for Perl::Types
>
> This document is the first step in the Proposed Perl Changes process:
>
> https://github.com/Perl/PPCs/blob/main/README.md
> ...

I've just spent an hour trying and to all intents and purposes failing
to read this document.

Am I excluded because <browser>?

--

73,
Ged.
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On 2023-08-16 12:06 a.m., G.W. Haywood via perl5-porters wrote:
> On Wed, 16 Aug 2023, Oodler 577 via perl5-porters wrote:
>> https://github.com/Perl/PPCs/blob/main/README.md
>
> I've just spent an hour trying and to all intents and purposes failing
> to read this document.
>
> Am I excluded because <browser>?

This is a simple documentation file on Github, which is a very widely used and
presumably thoroughly tested site.

I can read the page fine on 3 different web browsers, Safari, Firefox, Chrome,
all fairly new versions.

What browser are you using, and can you try a different one? My top
recommendation is Firefox.

-- Darren Duncan
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
Note: I accidentally sent this to Oodler directly, not CC'ing P5P.

On Wed, Aug 16, 2023 at 7:37?AM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:

>
> Perl lacks sufficient exposure of the already-existing real natural
> Perl data types for use by the programmer. This has lead to false
> claims that the Perl interpreter "has no data types". This has
> also lead to countless programmer-hours spent devising synthetic
> or unnatural type systems that rely entirely on fuzzy data guessing
> via regular expressions, etc.


This looks an awful lot like an end-run around the Oshun discussion which I
had to close because some very simple, but important, questions were not
being answered. When I asked (
https://github.com/orgs/Perl-Oshun/discussions/27#discussioncomment-6581803)
a few questions about Will's "real types" approach, there was no response.
Yves (demerphq) got right to the point with pointing out that Will's
approach is extremely unlikely to work:
https://github.com/orgs/Perl-Oshun/discussions/27#discussioncomment-6680632

I finally closed that discussion after waiting two weeks for answers that
never came. So let me ask them again here, in hopes that *someone* who
knows the answers is willing to share them.

1. Can type failures be downgraded to warnings or disabled entirely?

When you're working with a multi-million line code base, having production
come crashing to a halt because your "integer" recieved 3.14 instead of 3
is going to get types ripped out quickly. Thus, this approach would likely
be of little use for existing systems.

2. Gradual typing?

(this was in my original email) *Your examples show types applied to all
variables. I can't find any that show types being gradually added one at a
time. Is that allowed, or is it all or nothing? If it's the latter, it's
completely useless for existing systems.*

(this is new for this email(: gradual typing might be allowed because I've
found an example in the RPerl documentation. I'm unsure if it applies to
Perl::Types, but I would assume it does. However, that makes question 3
even more important.

3. Do these types play well with others?

Per Yves' response, it's unlikely they will. Thus, the following would be
fatal:

my $var1 = 234;my integer $var2 = 456; # Perl::Typesmy $total
= $var1 + $var2;

Does the above work or not? If it doesn't, you've just locked out the
entire CPAN. If that's the case, can you please provide some
interoperability use cases?

I previously asked them in good faith and waited in vain for a response.
Now I'm asking them in exasperation.

Best,
Ovid

On Wed, Aug 16, 2023 at 7:37?AM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:

> # Proposed Perl Changes Elevator Pitch for Perl::Types
>
> This document is the first step in the Proposed Perl Changes process:
>
> https://github.com/Perl/PPCs/blob/main/README.md
>
> Respectfully submitted by the _Perl::Types Committee_:
> * Will Braswell (WBRASWELL), Co-Founder & Chairman
> * Brett Estrade (OODLER), Co-Founder & 1st Vice Chairman
> * Zakariyya Mughal (ZMUGHAL), Co-Founder & 2nd Vice Chairman
> * John Napiorkowski (JJNAPIORK)
> * Darren Duncan (DUNCAND)
> * Nedzad Hrnjica (NHRNJICA)
> * Rohit Manjrekar (MANJREKAR)
> * Paul Millard (MAGUDAS)
> * Joshua Day (HAX)
> * Tyler Bird (BIRDTY)
> * Robbie Hatley (HATLEYSFT)
> * David Warner (WESTBASE)
> * Daniel Mera (DMERA)
> * Duong Vu (DVU)
> * Rajan Shah (RSHAH)
>
> ## Here is a problem
>
> Perl lacks sufficient exposure of the already-existing real natural
> Perl data types for use by the programmer. This has lead to false
> claims that the Perl interpreter "has no data types". This has
> also lead to countless programmer-hours spent devising synthetic
> or unnatural type systems that rely entirely on fuzzy data guessing
> via regular expressions, etc.
>
> Fortunately, the Perl compiler already provides the capability to
> expose the underlying real native C data types which can be used
> by Perl programmers to incrementally improve performance, eventually
> achieving the full native speed of compiled C code. Among other
> features, the Perl compiler also enables real natural data type
> checking with identical behavior in both dynamic (intrepreted) mode
> and static (compiled) mode.
>
> https://metacpan.org/dist/RPerl
>
> The data type subsystem of the Perl compiler is currently in the
> process of being extracted and refactored as an independant CPAN
> distribution called `Perl::Types`. This distribution provides new,
> core capabilities and thus should be included in the Perl core
> distribution as a "Dual-Life" module.
>
> https://github.com/Dual-Life
>
> ## Here is the syntax that we're proposing
>
> The Perl interpreter already has an unused slot in the grammar for
> this very purpose:
>
> `my TYPE $var;`
>
> The Perl interpreter and the Perl compiler already provide the
> basic data types to be used in the grammar slot above:
>
> * `boolean` (`SV` when `SvIsBOOL(sv)` is true, new in 5.36)
> * `integer` (`IV`)
> * `number` (`NV`)
> * `string` (`PV`)
> * `array` (`AV`) & `arrayref` (`RV(AV)`)
> * `hash` (`HV`) & `hashref` (`RV(HV)`)
> * user-defined classes
>
> Custom data structures are declared with compound or nested data
> types composed from the basic types above, for example:
>
> * `integer::arrayref`
> * `integer::arrayref::arrayref`
> * `integer::arrayref::hashref`
> * `integer::arrayref::arrayref::hashref`
> * `string::arrayref`
> * `MyClass::arrayref`
> * etc.
>
> Attempting to utilize incompatible data types gives the same behavior
> and same errors in both interpreted mode and compiled mode, for
> example:
>
> ```
> #!/usr/bin/perl
> use Perl::Types;
>
> sub squared {
> { my number $RETURN_TYPE };
> ( my number $base ) = @ARG;
> return $base ** 2;
> }
>
> squared(2); # FINE
> squared(2.3); # FINE
> squared(to_number('2')); # FINE
> my number $foo = 23;
> squared($foo); # FINE
>
> squared(); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value
> expected but ...
> squared('2'); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value
> expected but ...
> my string $bar = 'howdy';
> squared($bar); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value
> expected but ...
> squared([2]); # ERROR ENVxx, TYPE-CHECKING MISMATCH: number value
> expected but ...
> ```
>
> The syntax for arrays and hashes is similarly straightforward:
> ```
> sub multiply_array {
> { my number::arrayref $RETURN_TYPE };
> ( my integer $input_integer, my number::arrayref $input_array ) = @ARG;
> my number::arrayref $output_array = [
> $input_integer * $input_array->[0],
> $input_integer * $input_array->[1],
> $input_integer * $input_array->[2]
> ];
> return $output_array;
> }
>
> sub multiply_hash {
> { my number::hashref $RETURN_TYPE };
> ( my integer $input_integer, my number::hashref $input_hash ) = @ARG;
> my number::hashref $output_hash = {
> a => $input_integer * $input_hash->{a},
> b => $input_integer * $input_hash->{b},
> c => $input_integer * $input_hash->{c}
> };
> return $output_hash;
> }
> ```
>
> ## Here are the benefits of this
>
> The primary benefit of including `Perl::Types` in the Perl core
> distribution is that it will provide a greatly-needed capability
> of exposing the underlying C-level data types and data structures
> to every Perl programmer, so they may utilize Perl data types to
> achieve a number of benefits including but not limited to:
>
> * increased performance
> * code correctness
> * type safety (type checking)
> * memory safety (bounds checking)
> * documentation of code intent
> * potential for polymorphism
> * potential for derived or synthetic types
>
> Additionally, this foundational support for enabling Perl data
> types at the interpreter level will allow for the creation of
> synthetic or unnatural data types and data structures to be built
> on top of `Perl::Types` itself. For example, the capabilities
> provided in `Perl::Types` are necessary for any effort to introduce
> real natural type checking constraints related to Perl's new `class`
> keyword.
>
> ## Here are potential problems
>
> Because the Perl interpreter has already implemented both the real
> natural Perl data types, as well as the required `my TYPE $var`
> syntax construct, we therefore do not foresee the introduction of
> any significant issues by including `Perl::Types` in the Perl core
> distribution.
>
> The largest barrier to adoption for the Perl compiler is the need
> for numerous non-Perl dependencies, such as the C++ compiler and
> other libraries. This barrier will be completely removed for the
> `Perl::Types` distribution, due to being refactored out of the
> compiler distribution and removal of all non-core dependencies.
>
> On Behalf of the _Perl::Types Committee_,
> Brett Estrade
>
> --
> oodler@cpan.org
> oodler577@sdf-eu.org
> SDF-EU Public Access UNIX System - http://sdfeu.org
> irc.perl.org #openmp #pdl #native
>


--
Curtis "Ovid" Poe
--
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, Aug 16, 2023 at 6:37?AM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:

> # Proposed Perl Changes Elevator Pitch for Perl::Types
>
> This document is the first step in the Proposed Perl Changes process:
>
> https://github.com/Perl/PPCs/blob/main/README.md
>
> Respectfully submitted by the _Perl::Types Committee_:
> * Will Braswell (WBRASWELL), Co-Founder & Chairman
> * Brett Estrade (OODLER), Co-Founder & 1st Vice Chairman
> * Zakariyya Mughal (ZMUGHAL), Co-Founder & 2nd Vice Chairman
> * John Napiorkowski (JJNAPIORK)
> * Darren Duncan (DUNCAND)
> * Nedzad Hrnjica (NHRNJICA)
> * Rohit Manjrekar (MANJREKAR)
> * Paul Millard (MAGUDAS)
> * Joshua Day (HAX)
> * Tyler Bird (BIRDTY)
> * Robbie Hatley (HATLEYSFT)
> * David Warner (WESTBASE)
> * Daniel Mera (DMERA)
> * Duong Vu (DVU)
> * Rajan Shah (RSHAH)
>
> ## Here is a problem
>
> Perl lacks sufficient exposure of the already-existing real natural
> Perl data types for use by the programmer. This has lead to false
> claims that the Perl interpreter "has no data types". This has
> also lead to countless programmer-hours spent devising synthetic
> or unnatural type systems that rely entirely on fuzzy data guessing
> via regular expressions, etc.
>
> Fortunately, the Perl compiler already provides the capability to
> expose the underlying real native C data types which can be used
> by Perl programmers to incrementally improve performance, eventually
> achieving the full native speed of compiled C code. Among other
> features, the Perl compiler also enables real natural data type
> checking with identical behavior in both dynamic (intrepreted) mode
> and static (compiled) mode.
>
> https://metacpan.org/dist/RPerl
>
> The data type subsystem of the Perl compiler is currently in the
> process of being extracted and refactored as an independant CPAN
> distribution called `Perl::Types`. This distribution provides new,
> core capabilities and thus should be included in the Perl core
> distribution as a "Dual-Life" module.
>
> https://github.com/Dual-Life
>
> ## Here is the syntax that we're proposing
>
> The Perl interpreter already has an unused slot in the grammar for
> this very purpose:
>
> `my TYPE $var;`
>
> The Perl interpreter and the Perl compiler already provide the
> basic data types to be used in the grammar slot above:
>
> * `boolean` (`SV` when `SvIsBOOL(sv)` is true, new in 5.36)
> * `integer` (`IV`)
> * `number` (`NV`)
> * `string` (`PV`)
> * `array` (`AV`) & `arrayref` (`RV(AV)`)
> * `hash` (`HV`) & `hashref` (`RV(HV)`)
> * user-defined classes
>
> Custom data structures are declared with compound or nested data
> types composed from the basic types above, for example:
>
> * `integer::arrayref`
> * `integer::arrayref::arrayref`
> * `integer::arrayref::hashref`
> * `integer::arrayref::arrayref::hashref`
> * `string::arrayref`
> * `MyClass::arrayref`
> * etc.
>
> Attempting to utilize incompatible data types gives the same behavior
> and same errors in both interpreted mode and compiled mode, for
> example:
>

Frankly, this is all unworkable.

Perl has a very simple type system[1]. Imagining non-existent types to
exist isn't helpful. You may be able to create a system of checks on
assignment/passing, but that's a different thing entirely from those values
having these types. Given that anything can have references, those checks
can't truly provide invariants.

This is not a type system.

Leon

1: https://twitter.com/leon_timmermans/status/1659557093110587394
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, 16 Aug 2023 06:37:07 +0200, Oodler 577 via perl5-porters <perl5-porters@perl.org> wrote:

> # Proposed Perl Changes Elevator Pitch for Perl::Types

Y'all should mention that you already threw a non-functional dist onto CPAN,

https://metacpan.org/dist/Perl-Types

for which i sent feedback noting PAUSE permission issues, which you did not address then or now

https://gitlab.com/scienceperl/perl-types/-/issues/1

--
With regards,
Christian Walde
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On 8/16/23 03:06, G.W. Haywood via perl5-porters wrote:
> Hi there,
>
> On Wed, 16 Aug 2023, Oodler 577 via perl5-porters wrote:
>
>> # Proposed Perl Changes Elevator Pitch for Perl::Types
>>
>> This document is the first step in the Proposed Perl Changes process:
>>
>> https://github.com/Perl/PPCs/blob/main/README.md
>> ...
>
> I've just spent an hour trying and to all intents and purposes failing
> to read this document.
>
> Am I excluded because <browser>?
>
Try this

https://raw.githubusercontent.com/Perl/PPCs/main/README.md
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, 16 Aug 2023 09:19:37 +0200, Ovid <curtis.poe@gmail.com> wrote:

> 1. Can type failures be downgraded to warnings or disabled entirely? When you're working with a multi-million line >code base, having production come crashing to a halt because your "integer" recieved 3.14 instead of 3 is going to >get types ripped out quickly. Thus, this approach would likely be of little use for existing systems.

while i have other issues with the OP proposal (such as them uploading a broken dist to cpan and grabbing toplevel perms without discussion) i have to ask about this question

if i declare a moo/se attr as isa => Int, and send in 3.14, moo/se will also die

to my knowledge the only way around that is eval, so why would downgrades be needed, rather than proper testing and error catching? or is there a way to downgrade the type errors in moo/se?

--
With regards,
Christian Walde
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
Darren Duncan <darren@darrenduncan.net> wrote:
> On 2023-08-16 12:06 a.m., G.W. Haywood via perl5-porters wrote:
>>
>> Am I excluded because <browser>?
>
> This is a simple documentation file on Github, which is a very widely used and presumably thoroughly tested site.

Hot take: Can't be that well tested if it fails to work without JavaScript.


> What browser are you using, and can you try a different one?

`git clone https://github.com/Perl/PPCs` allows access without a browser, if necessary.


--
Arne Johannessen
<https://arne.johannessen.de/>
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
Hi there,

On Wed, 16 Aug 2023, Diab Jerius wrote:
> On 8/16/23 03:06, G.W. Haywood via perl5-porters wrote:
>> On Wed, 16 Aug 2023, Oodler 577 via perl5-porters wrote:
>>
>>> https://github.com/Perl/PPCs/blob/main/README.md
>>> ...
>> I've just spent an hour trying and to all intents and purposes failing
>> to read this document.
>>
>> Am I excluded because <browser>?
>
> Try this
>
> https://raw.githubusercontent.com/Perl/PPCs/main/README.md

Thank you.

That's legible, but most links to other documents appear as relative
to some unknown root and are thus inaccessible:

* [motivation.md](docs/motivation.md) - why do we want to do something
* [process.md](docs/process.md) - the initial version of the process
* [template.md](docs/template.md) - the PPC template
* [future.md](docs/future.md) - how we see the process evolving
* [others.md](docs/others.md) - what others do (or did), and what we can learn from them

--

73,
Ged.
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
Hi there,

On Wed, 16 Aug 2023, Darren Duncan wrote:
> On 2023-08-16 12:06 a.m., G.W. Haywood via perl5-porters wrote:
>> On Wed, 16 Aug 2023, Oodler 577 via perl5-porters wrote:
>>> https://github.com/Perl/PPCs/blob/main/README.md
>>
>> I've just spent an hour trying and to all intents and purposes failing
>> to read this document.
>>
>> Am I excluded because <browser>?
>
> This is a simple documentation file on Github, which is a very widely used
> and presumably thoroughly tested site.

Thanks very much for your reply.

Your presumption is, I think, unjustified. I believe there was a time
when github told me my browser wasn't supported, but it doesn't say
that now. It seems sometimes things render, and sometimes they don't.
The most common problem is not this current README.md issue, but the
fact that much of the embellishment renders in Palemoon as a rotating
icon, which apparently performs no function but prevents all further
interaction with this hapless user.

> I can read the page fine on 3 different web browsers, Safari, Firefox,
> Chrome, all fairly new versions.
>
> What browser are you using,

I'm using Palemoon. The only browser addon installed is uBlock Origin
which is disabled for github.

> and can you try a different one? My top recommendation is Firefox.

I switched to Palemoon very reluctantly after using Firefox for more
than a decade when Firefox became unworkable for me. On Palemoon I'm
currently running six windows with between them about 500 open tabs;
for example I have one window more or less devoted to the RFCs with
currently just over a hundred RFCs open in separate tabs. After some
months of experimentation I chose Palemoon because it was the closest
thing to Firefox that I could find which would do what I needed to do.
I'm not in any hurry to go through all that again.

But what if I'd said it was a Braille reader?

Using a different browser isn't a realistic option, and no matter what
browser I started from, if every time somebody suggested that I use a
different browser I actually did that, I think I'd need to be running
every existing browser. My thin desktop client is a Pi4B with 8GBytes
of RAM but even that isn't enough RAM to pander to the 21st century's
bells and whistles mentality. My wife still uses Firefox, but after a
major upgrade recently she's begun to find it unbearably slow and is
currently searching for alternatives.

For three months now we haven't been able to submit a meter reading to
our electricity supplier (Eon) with either Palemoon or Firefox, and my
wife sent the supplier a revised logo, with the 'n' replaced by 'ff'.

The fact that we're even having this conversation is a symptom of an
epic failure in the processes. Remind me why HTML in the first place?

Here at least, the tools are getting in the way so badly that I'm just
going to walk away from it.

--

73,
Ged.
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
In my opinion as a less experienced Perl programmer, I would have to say I
thoroughly approve of the premises behind Oshun. The idea behind
Perl::Types also is appealing to me, and I feel that potentially the two
systems could coexist, and much work has already been done on both. They
have very different use cases and goals. I am just curious whether Perl's
inherent types are broad enough or flexible enough for most people to use
them.

Avery

On Wed, 16 Aug 2023 at 22:16, G.W. Haywood via perl5-porters <
perl5-porters@perl.org> wrote:

> Hi there,
>
> On Wed, 16 Aug 2023, Darren Duncan wrote:
> > On 2023-08-16 12:06 a.m., G.W. Haywood via perl5-porters wrote:
> >> On Wed, 16 Aug 2023, Oodler 577 via perl5-porters wrote:
> >>> https://github.com/Perl/PPCs/blob/main/README.md
> >>
> >> I've just spent an hour trying and to all intents and purposes failing
> >> to read this document.
> >>
> >> Am I excluded because <browser>?
> >
> > This is a simple documentation file on Github, which is a very widely
> used
> > and presumably thoroughly tested site.
>
> Thanks very much for your reply.
>
> Your presumption is, I think, unjustified. I believe there was a time
> when github told me my browser wasn't supported, but it doesn't say
> that now. It seems sometimes things render, and sometimes they don't.
> The most common problem is not this current README.md issue, but the
> fact that much of the embellishment renders in Palemoon as a rotating
> icon, which apparently performs no function but prevents all further
> interaction with this hapless user.
>
> > I can read the page fine on 3 different web browsers, Safari, Firefox,
> > Chrome, all fairly new versions.
> >
> > What browser are you using,
>
> I'm using Palemoon. The only browser addon installed is uBlock Origin
> which is disabled for github.
>
> > and can you try a different one? My top recommendation is Firefox.
>
> I switched to Palemoon very reluctantly after using Firefox for more
> than a decade when Firefox became unworkable for me. On Palemoon I'm
> currently running six windows with between them about 500 open tabs;
> for example I have one window more or less devoted to the RFCs with
> currently just over a hundred RFCs open in separate tabs. After some
> months of experimentation I chose Palemoon because it was the closest
> thing to Firefox that I could find which would do what I needed to do.
> I'm not in any hurry to go through all that again.
>
> But what if I'd said it was a Braille reader?
>
> Using a different browser isn't a realistic option, and no matter what
> browser I started from, if every time somebody suggested that I use a
> different browser I actually did that, I think I'd need to be running
> every existing browser. My thin desktop client is a Pi4B with 8GBytes
> of RAM but even that isn't enough RAM to pander to the 21st century's
> bells and whistles mentality. My wife still uses Firefox, but after a
> major upgrade recently she's begun to find it unbearably slow and is
> currently searching for alternatives.
>
> For three months now we haven't been able to submit a meter reading to
> our electricity supplier (Eon) with either Palemoon or Firefox, and my
> wife sent the supplier a revised logo, with the 'n' replaced by 'ff'.
>
> The fact that we're even having this conversation is a symptom of an
> epic failure in the processes. Remind me why HTML in the first place?
>
> Here at least, the tools are getting in the way so badly that I'm just
> going to walk away from it.
>
> --
>
> 73,
> Ged.
>
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, 16 Aug 2023 09:20:08 +0200, Leon Timmermans <fawaka@gmail.com> wrote:

> On Wed, Aug 16, 2023 at 6:37?AM Oodler 577 via perl5-porters <perl5-porters@perl.org> wrote:
>> # Proposed Perl Changes Elevator Pitch for Perl::Types
>
> Frankly, this is all unworkable.
>
> Perl has a very simple type system[1]. Imagining non-existent types to exist isn't helpful. You may be able to create >a system of checks on assignment/passing, but that's a different thing entirely from those values having these >types. Given that anything can have references, those checks can't truly provide invariants.
>
> This is not a type system.
>
> Leon
>
> 1: https://twitter.com/leon_timmermans/status/1659557093110587394

Highly agreed.

I think it's a very important distinction that perl already HAS a type system, and that what some people think is a type system is indeed just runtime checks; and that modifying the existing type system is very hard, and building anything outside it would not be a type system at all, and if you want checks, think of them as checks.

--
With regards,
Christian Walde
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
Op 16-08-2023 om 11:57 schreef G.W. Haywood via perl5-porters:
> Thank you.
>
> That's legible, but most links to other documents appear as relative
> to some unknown root and are thus inaccessible:
>
> * [motivation.md](docs/motivation.md) - why do we want to do something
> * [process.md](docs/process.md) - the initial version of the process
> * [template.md](docs/template.md) - the PPC template
> * [future.md](docs/future.md) - how we see the process evolving
> * [others.md](docs/others.md) - what others do (or did), and what we
> can learn from them


The root obviously being the path to the current document, as with any
relative link.


HTH,

M4
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, Aug 16, 2023 at 2:37?PM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:


> [snip]
> Perl lacks sufficient exposure of the already-existing real natural
> Perl data types for use by the programmer.
>

At the pure-perl level, I probably agree with that assertion.
But XS has always provided me with the information that I need.

Perl::Types installs cleanly for me, and has an impeccable record with
cpan-testers.
My main concern at this stage would be:

> perldoc Perl::Types
No documentation found for "Perl::Types".

There's no way that I am going to look critically at a module that has no
documentation.

Cheers,
Rob
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, Aug 16, 2023 at 5:33?PM sisyphus <sisyphus359@gmail.com> wrote:
>
> Perl::Types installs cleanly for me, and has an impeccable record with cpan-testers.

Easy to do - it doesn't implement anything.
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Wed, Aug 16, 2023 at 04:37:07AM +0000, Oodler 577 via perl5-porters wrote:
> # Proposed Perl Changes Elevator Pitch for Perl::Types
[...]
> Fortunately, the Perl compiler already provides

By "Perl compiler", do you mean RPerl?

> #!/usr/bin/perl
> use Perl::Types;
>
> sub squared {
> { my number $RETURN_TYPE };
> ( my number $base ) = @ARG;
> return $base ** 2;
> }
>

That's weird perl syntax. What's @ARG and $RETURN_TYPE? Is this something
RPerl related?

In what circumstances are these type checks carried out / enforced? Is it
just on scalar and list assignment? Or more generally? For example, does
this croak?

sub mutate { $_[0] = 'foo' }
my number $x;
mutate($x);

Speaking as a perl internals expert, can you explain to me in general
terms how Perl::Types does its thing?


--
Indomitable in retreat, invincible in advance, insufferable in victory
-- Churchill on Montgomery
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
> Re: PPC Elevator Pitch for Perl::Types
> From: Dave Mitchell
> Date: August 18, 2023 09:19
> Subject: Re: PPC Elevator Pitch for Perl::Types
> Message ID: ZN83kPGe3bEaC5O4@iabyn.com

Hi Dave, thank you for your reply. Please see our answer inline,
below.

> On Wed, Aug 16, 2023 at 04:37:07AM +0000, Oodler 577 via perl5-porters wrote:
> > # Proposed Perl Changes Elevator Pitch for Perl::Types
> [...]
> > Fortunately, the Perl compiler already provides

> By "Perl compiler", do you mean RPerl?

Yes.

> > #!/usr/bin/perl
> > use Perl::Types;
> >
> > sub squared {
> > { my number $RETURN_TYPE };
> > ( my number $base ) = @ARG;
> > return $base ** 2;
> > }
> >

> That's weird perl syntax. What's @ARG and $RETURN_TYPE? Is this something
> RPerl related?

`@ARG` is just the alias for `@_`, provided by `English.pm`.

https://perldoc.perl.org/perlvar#@ARG

https://perldoc.perl.org/English

`$RETURN_TYPE` was the simplest pure-Perl syntax we could come up
with, which allows us to specify a subroutine's return type without
changing its behavior. Can you please suggest possible pure-Perl
syntax alternatives for specifying a subroutine return type, without
requiring any changes to the existing Perl internals?

> In what circumstances are these type checks carried out / enforced? Is it
> just on scalar and list assignment? Or more generally? For example, does
> this croak?

> sub mutate { $_[0] = 'foo' }
> my number $x;
> mutate($x);

The Perl compiler currently supports type enforcement for subroutine
calls, so that is our starting point for Perl::Types. Thus, your
example above would not croak, because the subroutine does not
specify any data types for its input arguments. Type checking is
simply disabled for subroutines without input argument types.

If you added `( my number $my_arg ) = @ARG;` to the top of your
`mutate()` subroutine, then yes it would croak with a complaint
`... number value expected but undefined/null value found ...`
because you never assigned a value to `$x`. This is achieved by
inserting calls to the appropriate type-checking C macros or
functions for each typed input argument, inserted immediately
following the `@ARG` statement. So for your `mutate()` subroutine,
Perl::Types would automatically call either the `number_CHECK()`
or `number_CHECKTRACE()` macro on the value received into `$my_arg`,
which is where the croaking occurs:

https://metacpan.org/release/WBRASWELL/RPerl-7.000000/source/lib/RPerl/DataType/Number.h#L137-149

```c
// [[[ TYPE-CHECKING MACROS ]]]
#define number_CHECK(possible_number) \
(not(SvOK(possible_number)) ? \
croak("\nERROR ENV00, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but undefined/null value found,\ncroaking") : \
(not(SvNOKp(possible_number) || SvIOKp(possible_number)) ? \
croak("\nERROR ENV01, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but non-number value found,\ncroaking") : \
(void)0))
#define number_CHECKTRACE(possible_number, variable_name, subroutine_name) \
(not(SvOK(possible_number)) ? \
croak("\nERROR ENV00, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but undefined/null value found,\nin variable %s from subroutine %s,\ncroaking", variable_name, subroutine_name) : \
(not(SvNOKp(possible_number) || SvIOKp(possible_number)) ? \
croak("\nERROR ENV01, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but non-number value found,\nin variable %s from subroutine %s,\ncroaking", variable_name, subroutine_name) : \
(void)0))
```

> Speaking as a perl internals expert, can you explain to me in general
> terms how Perl::Types does its thing?

As you can see in the C macros above, we are exposing the real
native Perl data types by directly accessing the `SvOK()`, `SvIOKp()`,
and `SvNOKp()` internals. Perl::Types is not inventing its own
definition of types, it is only exposing the already-existing real
native Perl data types such as `IV`, `NV`, `PV`, etc. Real native
Perl data structures can likewise be exposed by way of the `AV`
and `HV` Perl data types, by directly accessing `SvAROKp()` and
`SvHROKp()`:

https://metacpan.org/release/WBRASWELL/RPerl-7.000000/source/lib/RPerl/DataStructure/Array/SubTypes1D.cpp#L72-118
https://metacpan.org/release/WBRASWELL/RPerl-7.000000/source/lib/RPerl/DataStructure/Hash/SubTypes1D.cpp#L92-166

```c
boolean number_arrayref_CHECK(SV* possible_number_arrayref, const boolean no_croak)
{
if ( not( SvOK(possible_number_arrayref) ) ) { CROAK_OR_RETURN(no_croak, "\nERROR ENVAVRV00, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber_arrayref value expected but undefined/null value found,\ncroaking") }
if ( not( SvAROKp(possible_number_arrayref) ) ) { CROAK_OR_RETURN(no_croak, "\nERROR ENVAVRV01, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber_arrayref value expected but non-arrayref value found,\ncroaking") }

AV* possible_number_array;
integer possible_number_array_length;
integer i;
SV** possible_number_array_element;

possible_number_array = (AV*)SvRV(possible_number_arrayref);
possible_number_array_length = av_len(possible_number_array) + 1;

for (i = 0; i < possible_number_array_length; ++i) // incrementing iteration
{
possible_number_array_element = av_fetch(possible_number_array, i, 0);

if (not(SvOK(*possible_number_array_element))) { CROAK_OR_RETURN(no_croak, "\nERROR ENVAVRV02, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but undefined/null value found at index %"INTEGER",\ncroaking", i) }
if (not(SvNOKp(*possible_number_array_element) || SvIOKp(*possible_number_array_element))) { CROAK_OR_RETURN(no_croak, "\nERROR ENVAVRV03, TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but non-number value found at index %"INTEGER",\ncroaking", i) }
}

return 1;
}
```

(Please see the links above for `number_arrayref_CHECKTRACE()`,
etc.)

Type checking is currently controlled on a per-file basis using
the `TYPE_CHECKING` preprocessor directive:

https://metacpan.org/release/WBRASWELL/RPerl-7.000000/source/lib/RPerl/Test/TypeCheckingTrace/AllTypes.pm#L1-2

```perl
# [[[ PREPROCESSOR ]]]
# <<< TYPE_CHECKING: TRACE >>>
```

The `TYPE_CHECKING` directive can have a value of `OFF` for disabled,
`ON` to call the `foo_CHECK()` macros/functions, and `TRACE` to
call the `foo_CHECKTRACE()` macros/functions. The only difference
between `ON` and `TRACE` is the inclusion of the offending subroutine
and variable names for easier debugging.

Does that help answer your initial questions?

> --
> Indomitable in retreat, invincible in advance, insufferable in victory
> -- Churchill on Montgomery

On Behalf of the _Perl::Types Committee_,
Brett Estrade

--
oodler@cpan.org
oodler577@sdf-eu.org
SDF-EU Public Access UNIX System - http://sdfeu.org
irc.perl.org #openmp #pdl #native
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Sat, 19 Aug 2023 04:56:13 +0200, Oodler 577 via perl5-porters <perl5-porters@perl.org> wrote:

> On Behalf of the _Perl::Types Committee_,

You're speaking for 15 people here. Do any of you plan at any point to address the fact that when you actually factor out your planned boolean.pm and string.pm and upload it, PAUSE will just mark your upload as unauthorized because you ain't got the perms? Or the smash and grab y'all did on a bunch of top level names?

https://pause.perl.org/pause/authenquery?ACTION=peek_perms&pause99_peek_perms_by=a&pause99_peek_perms_query=wbraswell&pause99_peek_perms_sub=Submit

--
With regards,
Christian Walde
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Sat, Aug 19, 2023 at 02:56:13AM +0000, Oodler 577 via perl5-porters wrote:
> Does that help answer your initial questions?

'fraid not :-)

If I am understanding correctly, Perl::Types is intended to be something
which can be used stand-alone, independent of RPerl, and which you want to
be bundled with the perl core.

Within that context, how does adding 'use Perl::Types' at the top of a
perl (not RPerl) program do its thing? What mechanism are you using that
causes this line in a non-RPerl program to croak;

my number $x;
...
$x = 'foo'; # croak

e.g. is it a source filter, set magic attached to $x, or ...?

Also, from your reply about my mutator example not croaking by default,
this seems to imply that it's quite possible for $x to obtain a
non-numeric value under some circumstances. So, by default, what
circumstances will croak and which will silently allow $x to become
something other than a number? E.g. which of these lines croaks?

$x = 'foo';
$x =~ s/1/a/;
substr($x,0,1) = 'foo';
my $y = substr($x,0,1);

Just in general terms I'm still confused as to what effect adding
'Perl::Types' to my program will have, and how it achieves that effect.



--
A problem shared is a problem doubled.
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Sat, Aug 19, 2023 at 4:56?AM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:

> > In what circumstances are these type checks carried out / enforced? Is it
> > just on scalar and list assignment? Or more generally? For example, does
> > this croak?
>
> > sub mutate { $_[0] = 'foo' }
> > my number $x;
> > mutate($x);
>
> The Perl compiler currently supports type enforcement for subroutine
> calls, so that is our starting point for Perl::Types. Thus, your
> example above would not croak, because the subroutine does not
> specify any data types for its input arguments. Type checking is
> simply disabled for subroutines without input argument types.
>

What was being asked was about the behavior of the @_ array. $_[0] is an
alias to $x. Assigning to $_[0] is the same as assigning to $x. Why does it
suddenly lose its knowledge of its type when its in the sub?


> The `TYPE_CHECKING` directive can have a value of `OFF` for disabled,
> `ON` to call the `foo_CHECK()` macros/functions, and `TRACE` to
> call the `foo_CHECKTRACE()` macros/functions. The only difference
> between `ON` and `TRACE` is the inclusion of the offending subroutine
> and variable names for easier debugging.
>
> Does that help answer your initial questions?
>

That answers one of my questions about being able to disable them. It
doesn't answer my question about whether or not this will work:

my $var1 = 234;my integer $var2 = 456; # Perl::Typesmy $total
= $var1 + $var2;

You haven't answered my questions on github. You haven't answered them in
this thread. You haven't addressed Yves' concerns which were raised on
github, where he clearly explains *why* this proposal is not likely to work
(
https://github.com/orgs/Perl-Apollo/discussions/27#discussioncomment-6680632
).

Why are you not answering those questions?

--
Curtis "Ovid" Poe
--
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Sat, Aug 19, 2023 at 4:56?AM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:

> > In what circumstances are these type checks carried out / enforced? Is it
> > just on scalar and list assignment? Or more generally? For example, does
> > this croak?
>
> > sub mutate { $_[0] = 'foo' }
> > my number $x;
> > mutate($x);
>
> The Perl compiler currently supports type enforcement for subroutine
> calls, so that is our starting point for Perl::Types. Thus, your
> example above would not croak, because the subroutine does not
> specify any data types for its input arguments. Type checking is
> simply disabled for subroutines without input argument types.
>
> If you added `( my number $my_arg ) = @ARG;` to the top of your
> `mutate()` subroutine, then yes it would croak with a complaint
> `... number value expected but undefined/null value found ...`
> because you never assigned a value to `$x`. This is achieved by
> inserting calls to the appropriate type-checking C macros or
> functions for each typed input argument, inserted immediately
> following the `@ARG` statement. So for your `mutate()` subroutine,
> Perl::Types would automatically call either the `number_CHECK()`
> or `number_CHECKTRACE()` macro on the value received into `$my_arg`,
> which is where the croaking occurs:
>
>
> https://metacpan.org/release/WBRASWELL/RPerl-7.000000/source/lib/RPerl/DataType/Number.h#L137-149
>
> ```c
> // [[[ TYPE-CHECKING MACROS ]]]
> #define number_CHECK(possible_number) \
> (not(SvOK(possible_number)) ? \
> croak("\nERROR ENV00, TYPE-CHECKING MISMATCH,
> CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but
> undefined/null value found,\ncroaking") : \
> (not(SvNOKp(possible_number) ||
> SvIOKp(possible_number)) ? \
> croak("\nERROR ENV01,
> TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value
> expected but non-number value found,\ncroaking") : \
> (void)0))
> #define number_CHECKTRACE(possible_number, variable_name, subroutine_name)
> \
> (not(SvOK(possible_number)) ? \
> croak("\nERROR ENV00, TYPE-CHECKING MISMATCH,
> CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value expected but
> undefined/null value found,\nin variable %s from subroutine %s,\ncroaking",
> variable_name, subroutine_name) : \
> (not(SvNOKp(possible_number) ||
> SvIOKp(possible_number)) ? \
> croak("\nERROR ENV01,
> TYPE-CHECKING MISMATCH, CPPOPS_PERLTYPES & CPPOPS_CPPTYPES:\nnumber value
> expected but non-number value found,\nin variable %s from subroutine
> %s,\ncroaking", variable_name, subroutine_name) : \
> (void)0))
> ```
>
> > Speaking as a perl internals expert, can you explain to me in general
> > terms how Perl::Types does its thing?
>
> As you can see in the C macros above, we are exposing the real
> native Perl data types by directly accessing the `SvOK()`, `SvIOKp()`,
> and `SvNOKp()` internals. Perl::Types is not inventing its own
> definition of types, it is only exposing the already-existing real
> native Perl data types such as `IV`, `NV`, `PV`, etc. Real native
> Perl data structures can likewise be exposed by way of the `AV`
> and `HV` Perl data types, by directly accessing `SvAROKp()` and
> `SvHROKp()`:


And all of that is entirely wrong. Scalars have a has-a relationship with
IV/NV/PV/RV (with only two of them being mutually exclusive with each
other), and looking at it the right/wrong way can change three of these.
Your concept of a value being a number or not is entirely fictional.

Leon
Re: PPC Elevator Pitch for Perl::Types [ In reply to ]
On Sat, Aug 19, 2023 at 9:40?AM Dave Mitchell <davem@iabyn.com> wrote:

> On Sat, Aug 19, 2023 at 02:56:13AM +0000, Oodler 577 via perl5-porters
> wrote:
> > Does that help answer your initial questions?
>
> 'fraid not :-)
>
> If I am understanding correctly, Perl::Types is intended to be something
> which can be used stand-alone, independent of RPerl, and which you want to
> be bundled with the perl core.
>
> Within that context, how does adding 'use Perl::Types' at the top of a
> perl (not RPerl) program do its thing? What mechanism are you using that
> causes this line in a non-RPerl program to croak;
>
> my number $x;
> ...
> $x = 'foo'; # croak
>
> e.g. is it a source filter, set magic attached to $x, or ...?
>
> Also, from your reply about my mutator example not croaking by default,
> this seems to imply that it's quite possible for $x to obtain a
> non-numeric value under some circumstances. So, by default, what
> circumstances will croak and which will silently allow $x to become
> something other than a number? E.g. which of these lines croaks?
>
> $x = 'foo';
> $x =~ s/1/a/;
> substr($x,0,1) = 'foo';
> my $y = substr($x,0,1);
>
> Just in general terms I'm still confused as to what effect adding
> 'Perl::Types' to my program will have, and how it achieves that effect.
>

You're assuming that Perl::Types isn't all vaporware and this is a proposal
by people who know what they're doing. It all becomes much clearer when you
let go of those assumptions.

Leon

1 2 3  View All