in reply to Re: Function Prototypes and Array vs. List (Pt. 2)
in thread Function Prototypes and Array vs. List (Pt. 2)

The cause of all this fuss was use of a function in an existing library that is mostly, for some reason, prototyped. This is real code, not some "hypothetical misdesign".

I hardly ever prototype, only when I have to, such as those examples you mention. I've used prototypes before, and they caused all sorts of wierdness, so I stopped. This might have been when they were still considered neat and not inherently dangerous.

Because of this, I've come to rely on doing things like chaining functions together, not unlike your example, or saving repeated parameters in arrays. I don't suggest that you should expand your arrays into lists just because. Not at all. What I'm saying is that if the function is prototyped, then you have no choice, which is another way of saying "sometimes you just have to". That's not my reasoning, that's reality! If you don't use prototypes, then this isn't an issue, and that's probably the best course of action. If you do, then you're going to have to be prepared for the consequences, so you'd better have a really good reason.

Although it probably wasn't clear, the whole point of the original post was to validate the theory that, if one can't deprototype the target function, then the consequences are that you really have to do all this extra work to use that function properly. I was hoping for the programmatic equivalent of a rubber glove that could be used to idiomatically insulate code A from prototyped code B, but no such technique seems to be available. Not that I was depending on this, of course.

This is yet another reason why the widespread use of prototypes is not a great idea. In Perl 6, things look like they will be much smoother.
  • Comment on Re^N+1: Function Prototypes and Array vs. List (Pt. 2)

Replies are listed 'Best First'.
Re: Re^N+1: Function Prototypes and Array vs. List (Pt. 2)
by danger (Priest) on Jun 14, 2002 at 07:43 UTC
    if one can't deprototype the target function...

    If all you want to do is disable the prototype, then calling the function with & will do it --- beware that @_ is passed implicitly if you leave off the parens, and you'll have to adjust your argument passing for more complex prototypes (such as: (&@) or (\@)) to ensure the function gets what it is expecting.