Synopses/S32/Callable

From perl6.cz

Contents

TITLE

DRAFT: Synopsis 32: Setting Library - Callable

AUTHORS

   Tim Nelson <wayland@wayland.id.au>
   Larry Wall <larry@wall.org>

VERSION

   Created: 26 Feb 2009

   Last Modified: 3 May 2009
   Version: 2

The document is a draft.

If you read the HTML version, it is generated from the Pod in the pugs repository under /docs/Perl6/Spec/S32-setting-library/Callable.pod so edit it there in the SVN repository if you would like to make changes.

This document documents Code, Block, Signature, Capture, Routine, Sub, Method, Submethod, and Macro.

Roles

Callable

   role Callable {...}

The Callable role implies the ability to support postcircumfix:<( )>.

Code

   # Base class for all executable objects
   role Code {
       method Signature signature() {...}
       method Code      assuming(...) {...}
       method           do() {...} # See L<S12/Introspection>
       method Bool defined {...}
       # XXX What does do() return?  I mean, it's a "method body", but what's that?
   }

For Code, the .defined method returns whether a body has been defined. A body consisting only of ..., !!!, or ??? (with optional message arguments) does not count as defined.

To test if a name has been declared, look up the symbol in the appropriate symbol table.

Block

   # Executable objects that have lexical scopes
   role Block does Code does Callable {
       method next() {...}
       method last() {...}
       method redo() {...}
       method leave() {...}
       method labels() {...}
       method as() {...} # See L<S12/Introspection> and L<S02/Value types>
   }

Signature

# Function parameters (left-hand side of a binding)
role Signature {...}

Capture

# Function call arguments (right-hand side of a binding)
role Capture does Positional does Associative {...}

WrapHandle

role WrapHandle {...}

Classes

Routine

class Routine does Block {
     method WrapHandle wrap(Code $code) {...}
     method Routine    unwrap(Wraphandle $original) {...}
     method Str        name() {...}
     method Bool       multi() {...}
}

unwrap
See "Wrapping" in S06.
wrap
method wrap(Code $code) {...}

See "Wrapping" in S06.

Sub

   class Sub isa Routine {...}

Method

   class Method isa Routine {...}

Submethod

   class Submethod isa Routine {...} # XXX or should this be isa Sub

Macro

   class Macro isa Routine {...}

Additions

Please post errors and feedback to perl6-language. If you are making a general laundry list, please separate messages by topic.


Personal tools
Language