in reply to Re^4: Reason for this discrepancy with scalar?
in thread Reason for this discrepancy with scalar?

Thanks for the detailed and enlightening reply! :)

> should $i's initial value be regarded as a string or integer?

Ok I get your point.

I'd say regexes are string operations.

And parsing the capture group for occurrences of \d might be too complicated. Especially because (\d\.\d) is a float.

Anyway does Perl really set the IV slot in your example?

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^6: Reason for this discrepancy with scalar?
by dave_the_m (Monsignor) on Mar 16, 2024 at 16:31 UTC
    Anyway does Perl really set the IV slot in your example?
    No, perl regards it as a pure string at that point.

    It's just an example of what perl regards as an initial type and what we think of as a "useful" initial type not always coinciding. So I'm sceptical that putting in effort to make perl record the initial type is going to help serialisation as much as people expect.

    Dave.

      > So I'm sceptical that putting in effort to make perl record the initial type

      Well - as I just remembered - at least we don't need a new flag, but a type attribute.

      my TYPE VARLIST

      This obscure feature of my was already there since the very beginning of Perl 5

      > is going to help serialisation as much as people expect.

      I think not only serialization could profit here.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

        But lexical types largely don't do what people expect; in particular, they don't stop something which isn't an Int or whatever from being assigned to the lex var; nor do they coerce the assigned value to that type.

        In general, adding types to perl is a big topic which tends to trigger the occasional heated discussion on p5p and elsewhere.

        Dave.