guile-user
[Top][All Lists]
Advanced

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

Re: How to globally replace core binding?


From: Maxime Devos
Subject: Re: How to globally replace core binding?
Date: Tue, 28 Nov 2023 01:51:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

(set! copy-file improved-copy-file)

This replacement 100% functioning assumes no inlining, nobody capturing the old copy-file on the top-level, nobody calling the C function directly ...

If the original copy-file is implemented in Scheme, then to avoid inlining problems, the module defining copy-file should do

(set! copy-file copy-file).

That way, Guile's compiler/optimizer knows that the binding is mutable and should not inlined (well, Guile being Guile, every binding is mutable, but now it is mutable from the perspective of the inliner too).

Depending on whether 'copy-file' is just a stand-in for something else and depending on how the better copy-file works/how it is ‘better’, it might be better to eventually write a patch to replace copy-file with the improved better-file, as then the improved copy-file is more widely available. (As a long-term thing; for short-term ‘trying things out’, doing set! is much more practical.)

Best regards,
Maxime Devos.

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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