Re: RFC: api change for insert-text (Re: Bug report for signal "insert-text")



On Wed, 2003-11-05 at 16:00, muppet wrote:
i have it fixed, but i would like everyone's comments on the fix before
i commit it.  don't let the talk of marshalling and C data types scare
you, the real thing i need comments on is the fact that i want to watch
for changes in argument values for this signal and change the its call
signature (removing a parameter).

I don't see any way to solve this and not break the API, either. But did
you consider using return values for those modifiable values? Something
like:

  $entry -> signal_connect(insert_text => sub {
    my ($entry, $new_text, $position) = @_;

    my $substitutions =
      $new_text =~ s/Fuck you\./I like and respect you./g;

    if ($substitutions) {
      $position += (length("I like and respect you.") -
                    length("Fuck you.")) * $substitutions;
    }

    return ($new_text, $position);
  });

That seems more Perlish to me. I didn't look into implementing this in
XS, so there may of course be technical reasons that'd render this
solution impossible.

Bye,
-Torsten




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]