On Sat, Feb 12, 2005 at 03:16:20PM +0800, Autrijus Tang wrote:
> the toplevel sequencing only handles "IO of ..." types, so the junction
> above will not print anything.  Instead it may raise a warning of "using a
> Junction in a void context", or something equally ominous.

Thinking about it, that warnings should be "Using a Junction in Action
context".  The "Action" name is better because "IO" is already used for
handles.  I'll try to list some notable deviations here:

    * A new type, "Action", that represents actions that must be
      sequenced in order and may have side effects.

    * The default context for toplevel program is now "Action of List"
      (or "Action of Any").  Each semicolon-separated statement in it
      are evaluated in that context as well.

    * Change the destructive assignment ("=") operator, so the lvalue
      context (say "Scalar") may match a corresponding rvalue context 
      (i.e. "Action of Scalar"):

        multi sub print ([EMAIL PROTECTED]) returns Action of Bool { ... }
        $a  = print(3);  # $a.isa(Bool) -- launch the action
        $b := print(3);  # $b.isa(Action of Bool) -- not launched

    * Similarily, containers of Action objects won't launch them:

        # This prints nothing
        @b := [print(1), print(2), print(3)];

    * However, destructive assignment under "List of Action" context
      launches them in a sequence:

        # This prints 123
        @b = [print(1), print(2), print(3)];

I reckon that this treatment is fairly drastic.  However, if one writes
perl6 program under the perl5-like imperative subset (i.e. always use
destructive assignment), then all user-defined functions will be
evaluated under the Action context by default, so syntactic differences
may still be minimized.

As I'm not planning to implement it until I finish the OO parts, I'd
appreciate feedbacks on this idea.

Thanks,
/Autrijus/

Attachment: pgprRgtnoGKur.pgp
Description: PGP signature

Reply via email to