Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perl has For Types Or, Strengthening Perl’s Type System by Brian Clarke.

Similar presentations


Presentation on theme: "Perl has For Types Or, Strengthening Perl’s Type System by Brian Clarke."— Presentation transcript:

1 Perl has For Types Or, Strengthening Perl’s Type System by Brian Clarke

2 n ”[Perl] doesn't try to tell the programmer how to program. It lets the programmer decide what rules today, and what sucks. It doesn't have any theoretical axes to grind. And where it has theoretical axes, it doesn't grind them. Perl doesn't have any agenda at all, other than to be maximally useful to the maximal number of people. To be the duct tape of the Internet, and of everything else.” --Larry Wall n “Since you gave Perl a ridiculous request, Perl dutifully provides you in return a ridiculous response-- but not an error; oh no, not that!” --Tom Christiansen Philosophy

3 Fundamental Perl Types n Scalars –use $ –SCALAR := { integer U double U string U REFERENCE } –REFERENCE := scalar_reference | array_reference | hash_reference | REFERENCE n Arrays –lists of SCALAR n Hashes –mapping of { string -> SCALAR }

4 Contexts and Coercions n Thingys in Perl are evaluated in terms of the context in which they are used –scalar (void, boolean, string, number,…) –list (list of scalars) n Can have some *interesting* results –What is an array in scalar context? –Even better: what is a hash in scalar context?

5 use strict ‘types’; n Stricter definitions and contextual rules n enhanced compile-time and run-time checking n type information must be visible, and stored –necessitates additional syntax/keywords integer, double, string, *ref, typed_sub, etc. –internal representation must facilitate this interpreter already has a type bitmask add support to other types all types could be objects internally…future work n type check subroutine parameters

6 Oh, wait, you’re serious?! n YES. n “There’s More Than One Way To Do It”, so why not one more? n Interpreter has initial framework, at least for storing type information n coercion rule set would be reduced n my Dog $spot;

7 Perl6 RFCs  Several RFCs discuss/mention some of the ideas of this project (often very informally)  Everything in Perl becomes an object (RFC 161), All Perl core functions should return objects (RFC 73)  Stronger typing through tie (RFC 15)  Types and structures (RFC 122)  Subroutine prototypes and parameters (RFC 57)

8 Is it really useful? n More readable code n Easier to reason about behavior –human reading –compiler and runtime checking n More efficient code produced for backend –other VMs being targeted, compile-time type knowledge will help

9 Conclusions n Project meets evaluation criteria n Perl6 will probably see a number of these (or similar) ideas implemented n Perl will remain Perl: –everything for everyone –One More Way To Do It –nothing unPerlish about it


Download ppt "Perl has For Types Or, Strengthening Perl’s Type System by Brian Clarke."

Similar presentations


Ads by Google