Re: Contracts macro example

2022-08-04 Thread Maxime Devos
On 24-07-2022 03:21, Zelphir Kaltstahl wrote: (define-syntax require (identifier-syntax (syntax-error "'require' can only be used as part of a contract construct"))) Can you explain how it works? If you meant: how can identifier-syntax + syntax-error be used? -- I don't

Re: Contracts macro example

2022-07-23 Thread Zelphir Kaltstahl
Hello Maxime! I needed some time to implement the things you explained/mentioned, but I think I've got it now: https://notabug.org/ZelphirKaltstahl/guile-examples/src/87304cc573086b5ef60c1d3aad25d4431fd5bca8/macros/contract.scm There is still one issue though: The placeholder of the ensure

Re: Contracts macro example

2022-07-20 Thread Maxime Devos
On 20-07-2022 10:39, Zelphir Kaltstahl wrote: It would also be nice to define a global 'require' and 'ensure' and '' somewhere (e.g.: (define-syntax require (identifier-syntax (syntax-error "'require' can only be used as part of a contract construct", that way, require / ensure / can be

Re: Contracts macro example

2022-07-20 Thread Zelphir Kaltstahl
Hello Maxime! On 7/19/22 17:20, Maxime Devos wrote: Zelphir Kaltstahl schreef op do 14-07-2022 om 23:55 [+]:   (make-assertion-failure)   (make-exception-with-message "assertion failed")   (make-exception-with-irritants (quote (op args* ...)] Instead of a

Re: Contracts macro example

2022-07-19 Thread Maxime Devos
Zelphir Kaltstahl schreef op do 14-07-2022 om 23:55 [+]: >   (make-assertion-failure) >   (make-exception-with-message "assertion failed") >   (make-exception-with-irritants (quote (op args* ...)] Instead of a generic 'assertion failure', I believe a more specific

Contracts macro example

2022-07-14 Thread Zelphir Kaltstahl
Hello Guile users! I've tried myself again at writing some macros. Some post about programming language features inspired me to try and write a macro, which adds contracts (or my naive idea of what they are) to function definitions. The code is at: