Hi,

Juerd wrote:
> Ingo Blechschmidt skribis 2005-12-25 17:37 (+0100):
>> I disagree about binding only being a language thing:
> 
> I fail to see how your example code illustrates your disagreement.
> 
>>         return 42
>>             if (my $short := $long_parameter_name) == $specialcase;

I inferred that you think/thought that binding should/can't be used in
expressions:

Juerd wrote:
> That works very well, because binding as an expression makes no sense
> anyway, it being a language thing.

Thus I wanted to demonstrate that "binding as an expression" does make
sense (to me at least).

Sorry if I misinterpreted your post.

>>     push @foo, (my $head := pop @grtz);
> 
> A bit better style, but I'd still recommend against it.

Consider:

    my @sites = < abc.org def.org ghi.org >;
    loop {
        push @sites, (my $site := shift @sites);
        check_for_updates($sites);
        sleep ...;
    }

> You're doing something in an expression that has no effect on what
> happens in the expression itself.

Right; but I don't consider this as bad style or as "problematic".

Consider a perhaps more usual example:

    # Perl 5
    while(...) {
        process($tasks[$i++]);
        # The "++" does not have an effect on the expression itself,
        # writing "process($tasks[$i])" wouldn't make any difference.

        if(...) { $i--   }  # redo the last task
        if(...) { $i = 0 }  # redo all tasks
        if(...) { $i++   }  # skip next task
    }


--Ingo

Reply via email to