[-- Attachment #1.1: Type: text/plain, Size: 226 bytes --] Hi Guilers, I implemented srfi-89 (Optional positional and named parameters) https://gitlab.com/mjbecze/guile-srfi-89/ It is hygienic and reuses guile's lambda* so there is minimal overhead. Cheers!, -Martin Becze [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --]
Well done! Macros are great fun. I glanced through your source and could follow it without much hickups. You probably know this already, but you can actually do the sanitize-rest at compile time for cases where the procedure is not passed as an argument to some.other procedure.
Say we (define* (blah ...) Body...).
Then you define one function that does argument checking (%blah-check) at runtime and one that does not (%blah)
Then make the regular blah a macro. Using identifier macros you dispatch to %blah-check if it is not used in call position, or check all keyword arguments and sanitize them at compile time and dispatch it to %blah.
I spent some time implementing define-inlinable*, a keyword-aware define-inlinable, using that. I never baked it fully, so I never submitted a patch, but that is the approach I took, and the approach that define-inlinable uses which you can find in the guile sources.
--
Linus Björnstam
On Mon, 10 Aug 2020, at 22:07, Martin Becze wrote:
> Hi Guilers,
> I implemented srfi-89 (Optional positional and named parameters)
> https://gitlab.com/mjbecze/guile-srfi-89/
>
> It is hygienic and reuses guile's lambda* so there is minimal overhead.
>
> Cheers!,
> -Martin Becze
>
>
> Attachments:
> * signature.asc
[-- Attachment #1.1: Type: text/plain, Size: 1128 bytes --] On 8/10/20 4:26 PM, Linus Björnstam wrote: > Well done! Macros are great fun. I glanced through your source and could follow it without much hickups. Thanks! It has been good learning experience. > You probably know this already, but you can actually do the sanitize-rest at compile time for cases where the procedure is not passed as an argument to some.other procedure. > > Say we (define* (blah ...) Body...). > > Then you define one function that does argument checking (%blah-check) at runtime and one that does not (%blah) > > Then make the regular blah a macro. Using identifier macros you dispatch to %blah-check if it is not used in call position, or check all keyword arguments and sanitize them at compile time and dispatch it to %blah. > > I spent some time implementing define-inlinable*, a keyword-aware define-inlinable, using that. I never baked it fully, so I never submitted a patch, but that is the approach I took, and the approach that define-inlinable uses which you can find in the guile sources. > I hadn't thought of this at all. Interesting idea, might give it a try. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --]
Martin Becze <mjbecze@riseup.net> writes: > Hi Guilers, > I implemented srfi-89 (Optional positional and named parameters) > https://gitlab.com/mjbecze/guile-srfi-89/ > > It is hygienic and reuses guile's lambda* so there is minimal overhead. > > Cheers!, > -Martin Becze In https://gitlab.com/mjbecze/guile-srfi-89/-/blob/master/srfi/srfi-89.scm the header refers to guile-json a couple times. Leo