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

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.

  • Comment on Re^8: Reason for this discrepancy with scalar?

Replies are listed 'Best First'.
Re^9: Reason for this discrepancy with scalar?
by LanX (Saint) on Mar 16, 2024 at 18:19 UTC
    Yes I remember digging into it and the fields Pragma.

    And ....

    # this will generate a compile-time error my Foo $foo = Foo->new;

    I could see a use case in extending this already existing syntax for other purposes, like

    • allowing to translate a subset of Perl to inline C
    • helping IDEs to intellisense method expansions
    • defining an initial type (e.g. for serializers ; sic)

    But probably I'm naive.

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