Refactoring: introduce the function REGISTERED-SYSTEM
Introduce the function REGISTERED-SYSTEM to abstract over finding a registered system by name, without having to take the CDR of the pair with timestamp. Also, add or improve docstrings for several functions. This refactoring should not modify any semantics, except for introducing this new function.
could you not rush it? I have another idea in the backlog which doesn't introduce a new function, but I don't want to start another debacle in parallel.
* find-system-if-being-definded may miss a defined system if the cache is cleared. I think we should use =(cdr (system-registered-p name))= instead of calling =*asdf-cache*=. As a bonus, we'll be able to remove with-asdf-cache around the locate-system. * search-for-system-definition // NB search-for-system-definition can't be considered as preserving referential transparency, because it calls =*system-definition-search-functions*= and we can't tell whenever they have side-effects. That will require changing the order of functions used in =search-for-system-definition= (=find-system-if-being-defined= should go last?) The function will look something like this: #+BEGIN_SRC lisp (defun search-for-system-definition (system) (let ((name (coerce-name system))) (flet ((try (f) (if-let ((x (funcall f name))) (return-from search-for-system-definition x)))) (try (lambda (name) (first (consult-asdf-cache `(find-system ,name))))) (try 'sysdef-immutable-system-search) (map () #'try *system-definition-search-functions*) (try 'find-system-if-being-defined)))) #+END_SRC =find system-if-being-defined= was previously in the first place. Also =find-system-if-being-defined= includes results =sysdef-preloaded-system-search= since the last changes where preloaded systems are normal, defined systems, so we can remove that function. This function has to be the *last* in the list, because otherwise we would always have the same system here, and that's definetely not what we want to have. We definetely want to consult the cache here.
I think it's a bug, that
find-system-if-being-defineddoesn't find a defined system if it's not in the cache, even if it's registered. I've tried to see, if we exploit this misbehaviour and indeed we do, hence the change to
Great improvement in attitude: asking a question!
I believe you might be confused about fsibd: its purpose is explicitly to find systems being defined in the current asdf session (as embodied by its cache). It MUST NOT find systems defined before the session was started.
I'll improve the comments for this function: everything you get wrong is a bug on my part for not documenting the code enough.
I don't see improvement in refraining from personal remarks on the other hand.
Yes, that's why it should search in defined-systems, which contains systems defined in the current asdf session (cache may be cleared). Cache is meant for speeding up things and resolving circular dependencies, while defined systems are in
*defined-systems*hash table (which is accessed indirectly by
1- A system being defined is not defined yet.
2- No, the cache is meant for correctness, not just for speed: it imposes a coherent view of the world by any given ASDF session, when multiple filesystem dependent queries might yield inconsistencies that could cause incorrect behavior, infinite loops, etc.
*defined-systems*, it contains all systems registered, even in previous sessions. (The name is from ASDF 1; I would have called it
Cache may miss preloaded systems, which are defined systems. I'm not sure if I understand a difference, but could you verify that your assertion, that if the system isn't found in the cache means, that it's not defined? Or if treating
*defined-systems*as name suggest won't break the system? Interface inflation would be undesirable, if after all
find-system-if-definedcan fulfill this very purpose
The entire purpose of
search-for-system-definitionis to NOT CONSULT
*defined-systems*but to look for definitions outside of it.
(equal "if-being-defined" "if-defined")===>
beingmean then in that context? If being means
(consult-asdf-cache `(find-system ,name))
then it's hard to justify creating a function if its used only in one place. OK, I understand that checking defined systems isn't wanted in
search-for-system-definition, then it could look like
(defun search-for-system-definition (system) (let ((name (coerce-name system))) (flet ((try (f) (if-let ((x (funcall f name))) (return-from search-for-system-definition x)))) (try (lambda (name) (first (consult-asdf-cache `(find-system ,name))))) (try 'sysdef-immutable-system-search) (map () #'try *system-definition-search-functions*)) (try 'sysdef-preloaded-system-search)))
but again, if you are completely sure, that
if-being-defineddoesn't look for a defined system, but cached one, then OK. I would double check for a sake of not extending interface unnecessarily. I've elaborated my doubts here, I probably won't have much to add to this (non)issue.
Isn't there progressive present in Polish? That'd be interesting. There is in English.
Being defined == the definition is in progress in the current session. Started but not completed yet. In particular, the system hasn't been registered; and/or its registration could conceivably be undone, if not for search-for-system-definition treating this case specially.
Can you believe that I actually wrote that code for a reason? You can even look in the git logs what explanation I gave for introducing it, and read the bug report on launchpad.
There is progressive in Polish, my English isn't perfect though. Was there a reason to introduce a new function just for one place in the code?
Abstraction. The details of how parse-defsystem communicates with fsibd may evolve in the future.
And now, thanks to you, documentation. See 126.96.36.199.