This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
signatures #7
Comments
This was referenced Dec 24, 2015
Closed
rurban
pushed a commit
that referenced
this issue
Jan 5, 2016
not undef as in Perl5. We need that for introspection and don't want a new builtin. prototypes are a shorthand form of signatures anyway. Add a new CvSIGOP field to access the signature op from any CV. [GH #7]
Win32 VC 2013 32b, verbose testing.
|
The "out of memory" in signatures.t is
All process memory is exhausted extending the context stack to millions/billions of entries. Curcop points to this
line in signatures.t. That line seems to be doing infinite recursion. trying to add a dump of the perl callstack doesn't work
|
Thanks, but I see the msvc test results by myself on appveyor. The problem is actual debugging on the cxstack recursion problem.
|
rurban
pushed a commit
that referenced
this issue
Jun 3, 2016
not undef as in Perl5. We need that for introspection and don't want a new builtin. prototypes are a shorthand form of signatures anyway. Add a new CvSIGOP field to access the signature op from any CV. [GH #7] # Conflicts: # pod/perlcdelta.pod # pod/perlfunc.pod
Merged into master (v5.24.0c) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
TODO:
LATER:
STATUS:
old-style sigs to the new fast ones. this version uses the stack values directly, as with XSUBs. No @_ copying.
DONE:
(\@array)
and access it as$array->[]
arrayref, ditto for hashes. (done)bind scalarrefs transparently as in perl6 or
$_[n]
as in perl5.See https://github.com/perl11/cperl/commits/feature/gh7-signatures
Overview
p5p came with the worst of all signature implementions which already do exist. The slowest and with the least features, actually blocking critical progress. The newer one in a branch for 5.22 actually looks pretty good (OP_SIGNATURE), but needs a complete rewrite so I wait on this until this lands and stabilizes.
smoke-me/davem/op_signature3
Update: It didn't land, so we use the temp. version and improve it by ourselves. See
feature/gh7-signatures
https://github.com/perl11/cperl/commits/feature/gh7-signaturesmissing support for optional types
as provided for lexical variable declarations, in leading position as
with
my int $a;
and as attribute, as with($i :int :const)
we need to seperate core (int, str, num) and user-defined types (class names),
and :const. Maybe more later.
store the typestash similar as in pads. do it again with the new OP_SIGNATURE.
missing syntax for return types (as attr)
for easier implementation we support subattributes, : only.
Note that we can add
:method
and:const
also here.=> use i_add op
missing syntax and support for references, call-by-ref
with perl5 all arguments are copied only, as with
my $arg1 = shift;
butsyntax for fast
$_[0]
access is not provided.cperl uses
\$name
to denote references to scalar lvalues.with constant arguments use call-by-ref also.
e.g.
modifies the calling argument.
for now scalar lvalue references only,
\@a
or\%h
would be nice with type checks for arrayrefor hashref. maybe
\[$]
also.wrong overly slow treatment of @_
Use the stack ABI as with OPs and XS, and do not copy the args into @_ for each call.
@_ is empty. Use your own slurpy parameter.
This makes cperl signatures about 2x faster.
The following applies only to the old slow zefram purple signatures, which are not use anymore:
The elements of @_ are accessed via aelem, not aelemfast,
the arity check is overly big and needs two checks and big strings with fixed arity subs.
replace @_ with direct stackaccess ST(n) with OP_SIGNATURE.
=>
improve error reporting
In compile-time errors do not only print the position, also the declaration which is violated.
e.g.
Type of arg 1 to main::x must be arrayref (not a scalar ref) at -e line 1, near "\$a)"
=>
Type of arg 1 \@b to x must be arrayref (not a scalar ref) at -e line 1, near "\$a)"
Harmonize error message with the rest:
Not enough arguments for %s %s
as with the ops and notToo few arguments for %s %s
Add subroutine type and name to error message on arity errors:
Disallow nameless parameters
When they clash with the prototype syntax.
Proper signature types are not only a great help for catching errors
early. they are performance critical, see coffescript, dart, microsoft
typescript, facebook flow and hack. the type inferencer will not be
able to infer many types without explicit types. but with typed
signatures, besides the obvious solution of private methods or closed
classes we can inline most small methods, and improve most loops and
array accesses. it is also critical to implement multi methods, i.e. proper multi-dispatch,
which would enable a proper oo system within perl5.
Dios is close but a hack (PPI macros!), and only with Inside-Out objects.
The text was updated successfully, but these errors were encountered: