chicken-hackers
[Top][All Lists]
Advanced

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

[patch] initial support for functors in csm


From: Pietro Cerutti
Subject: [patch] initial support for functors in csm
Date: Thu, 12 Oct 2023 08:00:37 +0000
User-agent: NeoMutt/20231006-3-fdc654

Hi all,

the patch attached teaches csm some basics about functors, by adding support for recognizing the following two forms when scanning a file.

1. (functor (FUNCTORNAME (ARG1 EXPORTS1) ...) FUNCTOREXPORTS BODY)

This associates a module named FUNCTORNAME to the current file. The names ARG1... are kept track of, so an import of them from the functor body doesn't result on a dependency which wouldn't ever be materialized in any module (see for example the imports of M and N in the attached arith.scm).

2. (module NAME = (FUNCTORNAME MODULENAME1 ...))

This associates a module named NAME to the current file and registers FUNCTORNAME and all of MODULENAME1... as imports for the current module. Because csm doesn't allow to register mode than one module pre file, the functor instantiation needs to be in its own file (see for example the attached arith.num.scm file).

I haven't tackled (module NAME = FUNCTORNAME BODY ...) yet, but I can do that if there's consensus on this first part.

A set of .scm providing an example that can be built with the patched csm is also attached. Just dump them in a directory and launch "csm -program main".


Thanks!

--
Pietro Cerutti
I have pledged to give 10% of income to effective charities
and invite you to join me - https://givingwhatwecan.org

Attachment: csm-functor-support-1.patch
Description: Text document

Attachment: arith.mix.scm
Description: Text document

Attachment: arith.num.scm
Description: Text document

Attachment: arith.scm
Description: Text document

Attachment: arith.str.scm
Description: Text document

Attachment: main.scm
Description: Text document

Attachment: num.scm
Description: Text document

Attachment: str.scm
Description: Text document


reply via email to

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