develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #118477] [PATCH] Add an API to attach a signature string to a CV

Thread Previous | Thread Next
From:
Peter Martini via RT
Date:
June 20, 2013 17:24
Subject:
[perl #118477] [PATCH] Add an API to attach a signature string to a CV
Message ID:
rt-3.6.HEAD-2552-1371749078-856.118477-15-0@perl.org
On Thu Jun 20 09:19:02 2013, smueller@cpan.org wrote:
> On 06/17/2013 05:17 PM, Peter Martini via RT wrote:
> [sub signature strings patch]
> 
> The patch claims it's attaching a sub signature *string*, but unless I 
> missed it in my quick skimming, it's really attaching a sub signature 
SV.

True; the original iteration had just a char * pointer, but UTF support 
is important, so using an SV instead seemed like the best course.

> 
> I'd also like to know hear about how this fits in with the sub 
> signatures design (both for core and out-of-core use, though I 
> personally care more about the former).
> 
> In other words: How exactly do you expect to use this and how do you 
> expect signature *extensions* to use this?
> 

The use case for this API is to allow the various CPAN module, and an in 
core module, the ability to add a human readable description for use in 
auto-documentation / deparsing.  Calling this function on a CV would 
create a new SV whose string buffer would represent (the equivalent of) 
the original signature.  Small and simple rules the roost, so the intent 
is to not allow magic or more complicated objects, just cloning of the 
PV buffer and the UTF flag.

> Should this be officially an arbitrary, attached SV so that people can 
> attach meaningfully structured data, or should it be required to be a 
> string and a string only?

I would think the meaningful, structured data would be attached to the 
various pad entries, or as flags on the CV, as appropriate.  By allowing 
an arbitrary string to be attached, the core doesn't have to worry about 
round-tripping from some arbitrary syntax into a data structure and back

> 
> --Steffen
> 


Bigger picture is a few different pieces:

Piece 1: Simplest piece, this, which the existing CPAN modules can take 
advantage of easily, attach a string for Deparse or any other method 
listing to display the signature.

Piece 2: A prototype attribute, so the core will support a standard 
alternate to supply a prototype inline.  I'm cleaning up that one now 
and expect to create a ticket with my reasoning, if not code, tonight.

Piece 3: A parser hook so a module can parse a signature itself (as XS 
or a raw function pointer), and configure the CV / PAD appropriately.  
Lexically scoped.

Piece 4: A hook on the CV which can be executed in entersub at the point 
where defgv would be populated, so any parameter validation / 
initialization can be done before the sub is actually entered.

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=118477

Thread Previous | Thread Next


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