Business to Business information

Education      Industrial      Management
Promotion      Publishing      reports
Web Design      Auctions


p6apclps #84 Perl 6 Apocalypse

Search Engine Optimization (Optimisation) Videos
Search Engine Optimization (Optimisation) Videos Search Engine Optimization (Optimisation) Videos
Search Engine Optimization (Optimisation) Videos

Internet Advertising

Search Engines      Banners      Classifieds      Ezines
'How To' ebooks      Ideas      Promotion      Resources

http://www.perlfoundation.org/... - - whether the "Bare" vs "Parametric" distinction is useful. Some apparently "Bare" blocks are actually "Parametric" if they refer to $_ internally, even implicitly. And a "Bare" block is just a "Parametric" block with a signature of "()". More later.) [Update: There's no longer a Bare/Parametric distinction.] A "[psignature]" is a parenthesized signature: rule psignature :w { \( [signature] \) } And there is a variant that doesn't declare names: rule psiglet :w { \( [siglet] \) } (We'll discuss "siglets" later in their own section.) It's possible to declare a subroutine in an lvalue or a signature as if it were an ordinary variable, in anticipation of binding the symbol to an actual subroutine later. Note this only works with an explicit name, since the whole point of declaring it in the first place is to have a name for it. On the other hand, the formal subroutine's parameters *aren't* named, hence they are specified by a "[psiglet]" rather than a "[psignature]": rule scopedsubvar :w { [lexscope] [type]? &[subname] [psiglet]? [trait]* } rule unscopedsubvar :w { &[subname] [psiglet]? [trait]* } If no "[psiglet]" is supplied for such a declaration, it just uses whatever the signature of the bound routine is. So instead of: my sub foo (*@_) { print @_ } you could equivalently say: my &foo ::= sub (*@_) { print @_ }; (You may recall that "::=" does binding at compile time. Then again, you may not.) If there is a "[psiglet]", however, it must be compatible with the signature of the routine that is bound to it: my &moo(Cow) ::= sub (Horse $x) { $x.neigh }; # ERROR "Pointy subs" "Pointy subs" declare a closure with an unparenthesized signature: rule pointysub :w { -\] [signature] [block] } They may not take traits. Bare subs A bare block generates a closure: rule baresub :w { [block] { .find_placeholders() } } A bare block declaration does not take traits (externally, anyway), and if there are any parameters, they must be specified with placeholder variables. If no placeholders are used, $_ may be treated as a placeholder variable, provided the surrounding control structure passes an argument to the the closure. Otherwise, $_ is bound as an ordinary lexical variable to the outer $_. ($_ is also an ordinary lexical variable when explicit placeholders are used.) More on parameters below. But before we talk about parameters, we need to talk about types. Digression on types Well, what are types, anyway? Though known as a "typeless" language, Perl actually supports several built-in container types such as scalar, array, and hash, as well as user-defined, dynamically typed objects via "bless". Perl 6 will certainly support more types. These include some low-level storage types: bit int str num ref bool as well as some high-level object types: Bit Int Str Num Ref Bool Array Hash Code IO Routine Sub Method Submethod Macro Rule Block Bare Parametric Package Module Class Object Grammar List Lazy Eager (These lists should not be construed as exhaustive.) We'll also need some way of at least hinting at representations to the compiler, so we may also end up with types like these: int8 int16 int32 int64 uint8 uint16 uint32 uint64 Or maybe those are just extra "size" traits on a declaration somewhere. That's not important at this point. The important thing is that we're adding a generalized type system to Perl. Let us begin by admitting that it is the height of madness to add a type system to a language that is well-loved for being typeless. But mad or not, there are some good reasons to do just that. First, it makes it possible to write interfaces to other languages in Perl. Second, it gives the optimizer more information to think about. Third, it allows the S&M folks to inflict strongly typed compile-time semantics on each other. (Which is fine, as long as they don't inflict those semantics on the rest of us.) Fourth, a type system can be viewed as a pattern matching system for multi-method dispatch. Which basically boils down to the notion that it's fine for Perl to have a type system as long as it's optional. It's just another area where Perl 6 will try to have its cake and eat it too. This should not actually come as a surprise to anyone who has been following the development of Perl 5, since the grammatical slot for declaring a variable's effective type has been defined for some time

Channel: Education
Uploaded: November 30, 1999 at 12:00 am
Author: h4ck3rm1k3

Length: 06:22
Rating: N/A
Views: 2



Video Url:


Embed Code:

Video Comments

No comments.

Search Engine Optimization (Optimisation) Videos © 2007 All Rights Reserved.