develooper Front page | perl.perl5.porters | Postings from April 2011

Perl's volatile functional API

From:
Tom Christiansen
Date:
April 25, 2011 12:06
Subject:
Perl's volatile functional API
Message ID:
29491.1303758379@chthon
Parameter signatures for Perl's functions show significant volatility
between major releases.  This is important because it changes the syntax of
the language, and therefore the parse.  This impacts anyone aiming for
Perl code that acts the same across different releases.  I don't think 
use VERSION suffices, but it is certainly better than no signal whatsoever.

First, summary data: SIX different keywords, all of them array or hash
operators central to basic language mechanics, have experienced THREE
different prototypes across only twice that many production releases:

		6           8           10          12          14
               ---------   --------    -------     --------    --------
  pop          (\@)        (;\@)       (;\@)       (;\@)       (;+)
  shift        (\@)        (;\@)       (;\@)       (;\@)       (;+)
  splice       (\@;$;$@)   (\@;$$@)    (\@;$$@)    (\@;$$@)    (+;$$@)
  each         (\%)        (\%)        (\%)        (\[@%])     (+)
  keys         (\%)        (\%)        (\%)        (\[@%])     (+)
  values       (\%)        (\%)        (\%)        (\[@%])     (+)

These 39 keywords have had 2 different prototypes:

		6           8           10          12          14
               ---------   --------    -------     --------    --------
  abs          (;$)        (;$)        (_)         (_)         (_)
  alarm        (;$)        (;$)        (_)         (_)         (_)
  chomp        (@)         n/a         n/a         n/a         n/a
  chop         (@)         n/a         n/a         n/a         n/a
  chr          (;$)        (;$)        (_)         (_)         (_)
  chroot       (;$)        (;$)        (_)         (_)         (_)
  cos          (;$)        (;$)        (_)         (_)         (_)
  exp          (;$)        (;$)        (_)         (_)         (_)
  hex          (;$)        (;$)        (_)         (_)         (_)
  int          (;$)        (;$)        (_)         (_)         (_)
  lc           (;$)        (;$)        (_)         (_)         (_)
  lcfirst      (;$)        (;$)        (_)         (_)         (_)
  length       (;$)        (;$)        (_)         (_)         (_)
  lock         ($)         (\$)        (\$)        (\$)        (\$)
  log          (;$)        (;$)        (_)         (_)         (_)
  mkdir        ($;$)       ($;$)       (_;$)       (_;$)       (_;$)
  oct          (;$)        (;$)        (_)         (_)         (_)
  ord          (;$)        (;$)        (_)         (_)         (_)
  push         (\@@)       (\@@)       (\@@)       (\@@)       (+@)
  quotemeta    (;$)        (;$)        (_)         (_)         (_)
  read         (*$$;$)     (*\$$;$)    (*\$$;$)    (*\$$;$)    (*\$$;$)
  readline     ()          (;*)        (;*)        (;*)        (;*)
  readlink     (;$)        (;$)        (_)         (_)         (_)
  recv         (*$$$)      (*\$$$)     (*\$$$)     (*\$$$)     (*\$$$)
  ref          (;$)        (;$)        (_)         (_)         (_)
  require      (;$)        n/a         n/a         n/a         n/a
  rmdir        (;$)        (;$)        (_)         (_)         (_)
  setpgrp      (;$;$)      (;$$)       (;$$)       (;$$)       (;$$)
  sin          (;$)        (;$)        (_)         (_)         (_)
  sqrt         (;$)        (;$)        (_)         (_)         (_)
  substr       ($$;$;$)    ($$;$$)     ($$;$$)     ($$;$$)     ($$;$$)
  sysread      (*$$;$)     (*\$$;$)    (*\$$;$)    (*\$$;$)    (*\$$;$)
  syswrite     (*$;$;$)    (*$;$$)     (*$;$$)     (*$;$$)     (*$;$$)
  tie          n/a         n/a         n/a         n/a         (\[$@%*]$@)
  tied         n/a         n/a         n/a         n/a         (\[$@%*])
  uc           (;$)        (;$)        (_)         (_)         (_)
  ucfirst      (;$)        (;$)        (_)         (_)         (_)
  unpack       ($$)        ($$)        ($;$)       ($;$)       ($;$)
  unshift      (\@@)       (\@@)       (\@@)       (\@@)       (+@)
  untie        n/a         n/a         n/a         n/a         (\[$@%*])

And these eight keywords are new to the language during that time:

		6           8           10          12          14
               ---------   --------    -------     --------    --------
  readpipe     UNFUNCT     UNFUNCT     (_)         (_)         (_)
  break        UNFUNCT     UNFUNCT     ()          ()          ()
  continue     UNFUNCT     UNFUNCT     ()          ()          ()
  default      UNFUNCT     UNFUNCT     n/a         n/a         n/a
  given        UNFUNCT     UNFUNCT     n/a         n/a         n/a
  say          UNFUNCT     UNFUNCT     n/a         n/a         n/a
  state        UNFUNCT     UNFUNCT     n/a         n/a         n/a
  when         UNFUNCT     UNFUNCT     n/a         n/a         n/a


Notes:

    UNFUNCT means prototype("CORE::$f") raised an exception in that release.
    n/a     means prototype("CORE::$f") returned undef in that release.
    ()      is a void prototype.

Releases tested:

    6 == 5.6.1
    8 == 5.8.8
   10 == 5.10.0
   12 == 5.12.3
   14 == 5.14.0 RC1
   
To better eyeball exactly when changes first appeared and what
those were, simple run the following program.  

--tom




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About