gisle / tcl.pm

Tcl extension module for Perl
http://search.cpan.org/dist/Tcl
9 stars 8 forks source link

Remove insure_ptrarray() to simplify tests #49

Closed chrstphrchvz closed 2 years ago

chrstphrchvz commented 2 years ago

Tests (added in 936e08774bda2c88ac27212bead7188b359ee980, 357b71b0671b86346c7d0a404cbcccb4dc30706d, and 717743b5bafcb8a21daf9cb55bdd9ad80da6949e) have this subroutine:

sub insure_ptrarray{
  my $inter=shift;
  my $list = $inter->icall(@_);
  if (ref($list) ne 'Tcl::List') {  # v1.02
      $list=[split(' ',$list)];
      }
return $list;
}

I have not located anyone else’s explanation for why this routine was needed, or the relevance of the v1.02 comment. I presume the subroutine is to deal with how $inter->icall(…) etc. in SCALAR context does not return a ref to something ARRAY-like when the Tcl result is an empty list (which is behavior from long before and after 1.02). If the code expects an array, though, then it should just use the simpler approach of $inter->icall(…) in LIST context. (And code actually needing to split a stringified Tcl list should set a better example and use $inter->SplitList(…) rather than split(' ', …).)