HaloO,

On Monday, 16. June 2008 10:11:49 Ovid wrote:
> For example, should the pre/postfix '++' be
> listed as having a side-effect?

I think so. But the scope where these side-effects take
place is important as well. In your second example below
the side-effect is restrained to the subs scope. That
should be considered harmless. The more global a
side-effect takes place, the more you get into spooky
action at a distance and unpredictable behavior.

>   sub side_effect    { return $_[0]++ }
>   sub no_side_effect { my $x = shift; return $x++ }
>
> In Perl 6, since arguments to subs would have to be specifically
> written as 'is rw', we might be able to minimize this issue, but I
> don't know if we can stop it.

I would think that it should be possible to enforce methods that
don´t modify the invocant mostly at compile time. The rest could
use a STORE instrumentation on MOP level that fails on any modification.
Then a where clause could temporarily install that for the evaluation
of its body. Also access to outer namespaces can easily be blocked
or restricted.


Regards, TSa.
-- 
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to