> Well, as discussed briefly in an earlier thread, 
> http:[EMAIL PROTECTED]/msg08514.html
> if we allow ! in function names, we can distinguish between the normal
> and in-place versions of functions without proliferating the number of
> keywords.
> 
>     chomp! $string;
>     my $chomped_string = chomp $string; 

I've been trying to work out if there is a possible unification
with assignment operators. Compare:

        $a.operator:+=(1);
        $a.chomp;

Both modify their object. However, I think the issue my be more
fundamental

In fact, in most OOPLs, operations do modify their object while
queries don't. A common strategy is to use a C<clone> method
when you want don't want to change the object of the operation.

The use of decorations to distinguish uses of nouns is standard
in perl culture ($@%). We don't currently use anything to
distinguish verbs. I know it uses valuable characters, but
adding C<chomp?> to identify a query, and C<chomp!> for an
operation does not seem unreasonable.

Unfortunately, the use of "!" to mean modify_in_place is potentially
ambiguous, because it is a unary operator. I would expect "foo!$a" to
parse as "foo(!$a)", not "(foo!)$a"

Another possibility would be use use C<$a->chomp> for operations
and C<$a.chomp> for the query, but this doesn't help for the
infix form.

Obvious alternatives such as "chomp= $a" suffer the same flaw.
Damian's suggestion of chomp: may be better, if I can teach my
brain to scan it.

I can't reach a conclusion in my own mind, so I thought I'd throw
out my thoughts.


Dave.

Reply via email to