Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the canonical way to document a type created via DEFSTRUCT? #36

Open
iamFIREcracker opened this issue Jul 26, 2024 · 1 comment

Comments

@iamFIREcracker
Copy link

Both the CLASS and TYPE locatives seem to get the job done, so I might end up just picking one or another, by why isn't there a STRUCT locative? I did not use neither DEFCLASS nor DEFTYPE to define this TYPE, so neither one of CLASS or TYPE felt natural to use, when documenting my API.

If you were open to such an enhancement, and confirmed it wasn't too challening to implement, I might just give it a try.

@melisgl
Copy link
Owner

melisgl commented Jul 27, 2024

As you found, so far I made do with only the CLASS or TYPE locatives plus STRUCTURE-ACCESSOR for the slots. But I do agree that being a structure can be part of the contract (e.g. to allow DEFSTRUCT :INCLUDE).

If you want to take a stab at implementing it, the CONDITION locative should be a good starting point. And since structures are a general CL thing, the implementation belongs in mgl-pax/dref. The steps that I can see are basically:

  • dref/src/base/package.lisp
    • @TYPELIKE-LOCATIVES: add STRUCTURE
    • @DREF-SUBCLASSES: add STRUCTURE-DREF
  • dref/src/full/locatives.lisp
    • cargo-cult the CONDITION locative
  • dref/test/test-locate.lisp
    • add TEST-LOCATE/STRUCTURE
  • dref/test/test.lisp
    • TEST-DSPEC
    • TEST-DEFINITIONS
    • TEST-DOCSTRING
    • *SOURCE-LOCATION-TEST-CASES*

There may be portability issues, but I'm happy to iron those out if it works at least SBCL. Let me know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants