Ken Fox <[EMAIL PROTECTED]> wrote:
> John Tobey wrote:
> > The Perl 5 (and older) behavior may preclude some optimizations.
>
> I can't think of any optimizations @_ assignment precludes.
> If we don't analyze dataflow to figure out if a sub modifies its
> args, then we just assume it will.
Suppose we use the low 2 bits as a type marker, so 30-bit ints are
representable directly in the "SV*". To preserve in-out semantics, we
would have to pass the address of this single-word object instead of
the single word itself. The same might apply if we had a way to
specify or infer argument types, so
SV* my_sub(SV*, SV*, SV*)
might be compiled as:
IV my_sub(UV, NV, SV*)
> Is this just a style issue? Why would you allow it with a
> prototyped function?
Prototyping here is a way to override the default semantics. A
prototype says, "I know what I'm doing, let me have it my way."
> The following is fully prototyped and
> still hard to optimize without dataflow:
When prototyping, the programmer assumes responsibility for (and,
ideally, finer control over) some aspects of optimization. This could
give greater opportunities in exchange for a little effort if, for
example, prototypes were allowed to specify pass-by-value or
-by-reference. (\$ kind of does this, but not in an optimal way, as
it uses a Perl-level reference.)
-John
--
John Tobey, late nite hacker <[EMAIL PROTECTED]>
\\\ ///
]]] With enough bugs, all eyes are shallow. [[[
/// \\\