public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* macro definition in module
@ 2023-10-12 21:19 Damien Mattei
  2023-10-12 21:33 ` Per Bothner
  2023-10-12 21:41 ` Damien Mattei
  0 siblings, 2 replies; 3+ messages in thread
From: Damien Mattei @ 2023-10-12 21:19 UTC (permalink / raw)
  To: kawa mailing list

i know how to define a function in module,example

;; file ModuleName.scm

(define-simple-class ModuleName ()

 ((string-null? str)
   (string=? str "")))

but this syntax can help me to define a macro in module, is it possible?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: macro definition in module
  2023-10-12 21:19 macro definition in module Damien Mattei
@ 2023-10-12 21:33 ` Per Bothner
  2023-10-12 21:41 ` Damien Mattei
  1 sibling, 0 replies; 3+ messages in thread
From: Per Bothner @ 2023-10-12 21:33 UTC (permalink / raw)
  To: Damien Mattei, kawa mailing list



On 10/12/23 14:19, Damien Mattei via Kawa wrote:
> i know how to define a function in module,example
> 
> ;; file ModuleName.scm
> 
> (define-simple-class ModuleName ()
> 
>   ((string-null? str)
>     (string=? str "")))
> 
> but this syntax can help me to define a macro in module, is it possible?

Your example defines a method in a class (in a module).
Each module is compiled to a "module class" but when a module contains a simple class
with the same name, they are combined:
https://www.gnu.org/software/kawa/Module-classes.html#Same-class-for-module-and-defined-class

However, if you want to define a macro in a module, you have you have to use a separate
module class, because you can't define a macro in a simple class.

I suggest reading this thoroughly:
https://www.gnu.org/software/kawa/Module-classes.html
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: macro definition in module
  2023-10-12 21:19 macro definition in module Damien Mattei
  2023-10-12 21:33 ` Per Bothner
@ 2023-10-12 21:41 ` Damien Mattei
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Mattei @ 2023-10-12 21:41 UTC (permalink / raw)
  To: kawa mailing list

solution:

(module-name overload2)

(export foo bar)

(define (foo) '())


(define-syntax bar

  (syntax-rules ()

    ((_ proc) '())))

having some example in this documentation
https://www.gnu.org/software/kawa/Module-classes.html would make Kawa
more easy to use;

On Thu, Oct 12, 2023 at 11:19 PM Damien Mattei <damien.mattei@gmail.com> wrote:
>
> i know how to define a function in module,example
>
> ;; file ModuleName.scm
>
> (define-simple-class ModuleName ()
>
>  ((string-null? str)
>    (string=? str "")))
>
> but this syntax can help me to define a macro in module, is it possible?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-12 21:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12 21:19 macro definition in module Damien Mattei
2023-10-12 21:33 ` Per Bothner
2023-10-12 21:41 ` Damien Mattei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).