Hi there,
until now, I had a tendency to split a library into several systems (more or less without thinking much) as soon as such or such feature was conditional (e.g. depending on CFFI availability, thread support, etc.).
Now I realize that in many cases, a conditionally included module or component would suffice, and so I'm starting to think that maybe I should do that, unless it makes sense for the conditional part to be loaded sort of standalone, independently from the rest, in which case a subsystem is more appropriate.
So my question is: WDYT, is there a general recommendation about this?
Thanks.
Sorry in advance for not exactly answering your question, but out of curiosity, what would 'conditionally included' entail exactly?
I ask because I've had trouble in the past where I erroneously used #+/#- in order to conditionalize a dependency - eg. define this function if some feature was loaded. But I ran into two problems. Specifically, stale FASLs: I had loaded my code after having loaded library X which I conditionally relied on (again via #+/#-). But on another boot of my lisp image, I did not load library X and got subsequent errors loading the asdf system because the FASLs were 'stale' in a way ASDF did not know about.
BTW See ASDF's `:if-feature` option.
Good luck
On Wed, May 18, 2022 at 5:49 AM Didier Verna didier@didierverna.net wrote:
Hi there,
until now, I had a tendency to split a library into several systems (more or less without thinking much) as soon as such or such feature was conditional (e.g. depending on CFFI availability, thread support, etc.).
Now I realize that in many cases, a conditionally included module or component would suffice, and so I'm starting to think that maybe I should do that, unless it makes sense for the conditional part to be loaded sort of standalone, independently from the rest, in which case a subsystem is more appropriate.
So my question is: WDYT, is there a general recommendation about this?
Thanks.
-- Resistance is futile. You will be jazzimilated.
Lisp, Jazz, Aïkido: http://www.didierverna.info
Wilfredo Velazquez zulu.inuoe@gmail.com wrote:
Sorry in advance for not exactly answering your question, but out of curiosity, what would 'conditionally included' entail exactly?
Conditional in the ASDF sense, that is...
BTW See ASDF's `:if-feature` option.
... exactly that, or :feature, etc.
This discussion makes me worried that `if-feature` dependencies may not function properly in ASDF. AFAIK ASDF still relies only on the file system to determine whether a file needs recompilation. But changing feature values are not, in general, visible in the file system. So I believe that use of `:if-feature` could cause ASDF to fail to recompile files when it should.
See this issue: https://gitlab.common-lisp.net/asdf/asdf/-/issues/117
If anyone has time to check my work on this, I would be grateful.
We may need to project feature state into the filesystem in order to fix this problem.
On 18 May 2022, at 6:27, Didier Verna wrote:
Wilfredo Velazquez zulu.inuoe@gmail.com wrote:
Sorry in advance for not exactly answering your question, but out of curiosity, what would 'conditionally included' entail exactly?
Conditional in the ASDF sense, that is...
BTW See ASDF's `:if-feature` option.
... exactly that, or :feature, etc.
-- Resistance is futile. You will be jazzimilated.
Lisp, Jazz, Aïkido: http://www.didierverna.info
using :if-feature is not deterministic (it depends on e.g. the load order of systems, unless fixed, see Robert's mail).
using subsystems that explicitly record dependencies is deterministic.
we once used asdf-system-connections, and the non-determinism that it introduced was a source of long hours of headaches... once we moved on to use subsystems and system names like :mylib+swank, it was all gone. - attila