develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [perl #20463] I want prototype() to modify the prototype of a function

Thread Previous | Thread Next
February 10, 2003 17:58
Re: [perl #20463] I want prototype() to modify the prototype of a function
Message ID:
Mark-Jason Dominus (via RT) <> wrote:
:The currnt prototype() builtin function returns the prototype of some
:other function.  For example
:        sub bleh ($) { return $_[0] }
:        print prototype('bleh');
:This prints '$'.
:But there is no convenient way to modify the prototype of an existing
:It seems to me that allowing
:        prototype(FUNCTION, '$$;$')
:would be straightforward and would not break any old code.  

I think the need for this is pretty rare, so it may be that Rafael's
suggested Inline/C code is sufficient.

Note that you can currently write this, which we should maybe class as
a bug:
  crypt% perl -wle 'sub a ($) { 1 } print prototype(1, \&a)'
.. though at least prototype(\&a, '$$;$') would give a:
  Useless use of reference constructor in void context
.. and return undef.

I worry also what happens to code calling the function that got
compiled before the prototype changed. Not sure if they would cause

If we were to consider changing the meaning of core prototype(),
we should maybe also consider allowing this usage only when
C< no strict 'prototypes' >.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About