-
Notifications
You must be signed in to change notification settings - Fork 15
Procedural function attribute macro, Optional argument handling #18
Comments
How a procedural macro can improve argument coercions? |
If nothing else, macro_rules style macros are too unwieldy to make sufficient improvement (at least they are for me) and I think they are also incapable of branching logic, as is required for I think it would be super cool to utilize a wasm_bindgen style attribute macro, such that the same rust function is able to accommodate rust callers and Perl callers. It could more tightly integrate with the struct argument unpacking derive macro I wrote earlier as well. |
I wasn't really arguing against improving syntax; I agree that the current But some of the improvements you want to make by switching to procedural macro don't make much sense to me. Functions require all formal parameters to be specified quite deliberately, inspired by the behavior of xsubpp and perl's own subroutine signatures. If anything, I'd like to make it even more strict and die when too many parameters are supplied too (to make it even more like xsubpp and perl signatures). This is different story for another issue, but the point here is that this isn't really a limitation of the macro itself.
Otherwise, sounds cool! :) I'm interested to see how this pans out. |
One of the situations I'm trying to accommodate is this:
Valid perl-side calling scenario 1:
Valid perl-side calling scenario 2
if Making this change also provides an opportunity to:
|
Objectives:
At present, the xs! macro is unable to handle Option arguments which may be omitted by the perl caller.
I propose that we do away with the
xs!
macro_rules in favor of a procedural function attribute macro, similar to wasm_bindgen or the pyo3 crate.Proposed syntax:
By doing this as a procedural macro, this will also improve the ability to perform smarter argument handling / coercion, including derive structs, optional context argument, etc.
The goal here is to have a perfectly ordinary rust function be callable from within perl with little or no special accommodation for the perl guts, at least in some circumstances.
The text was updated successfully, but these errors were encountered: