guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write a macro which defines a procedure


From: Zelphir Kaltstahl
Subject: Re: Write a macro which defines a procedure
Date: Sun, 21 Jul 2019 14:41:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

Hello Arne!

Thanks for posting those links!

I think your "already defined macro check" is part of what I was looking
for. I say part, because I was looking for something, that probably does
not exist: Something that checks for existing macros and for existing
procedures or other after compile-time defined things. However, the
macro runs before those things are even evaluated, so I guess the only
option would be to inspect the code and then find out what is defined.
This is not really practical.

So now I think that your check is actually as far as one can reasonably go.

Regards,

Zelphir

On 7/20/19 6:00 PM, address@hidden wrote:
> Message: 2
> Date: Sat, 20 Jul 2019 09:04:56 +0200
> From: Arne Babenhauserheide <address@hidden>
> To: address@hidden
> Subject: Re: Write a macro which defines a procedure
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset="utf-8"
>
>
> zelphirkaltstahl <address@hidden> writes:
>
>> Hi Guile Users,
>>
>> I want to write a macro, which creates a procedure of given name,
>> where the given name is a not yet defined identifier.
>> Here is what I have so far:
>
>
>> Anyway, can you help me out writing the macro, fixing at least the 2
>> issues or direct me to a tutorial, which covers how to write a macro
>> which gives basically a new define form?
> I can’t debug your form right now, but I can give you an example where I
> created macros to write macros:
>
> https://bitbucket.org/ArneBab/wisp/src/5e860c746ee02c764bf378aeb8f436a1a341bd5c/examples/enter-three-witches.scm#lines-209
>
> The Enter-Macro defines a macro which outputs its arguments as text.
>
> It took me some time to get it right, but it works pretty well.
>
> Bits and pieces:
> - check for the presence of a macro-binding:
> (syntax-case x ()
>    ((_ (name more ...) b ...)
>      ; new binding: only create it if the binding is not already a macro
>      (not (eq? 'macro (syntax-local-binding (syntax name))))
>      
> - stay on the same level:
>   #'(begin …
>
> (this is originally written in wisp and then transformed to scheme for
> easier sharing with other schemers:
> https://bitbucket.org/ArneBab/wisp/src/5e860c746ee02c764bf378aeb8f436a1a341bd5c/examples/enter-three-witches.w#lines-209
>  )
>
> Best wishes,
> Arne


reply via email to

[Prev in Thread] Current Thread [Next in Thread]