Sorry for the weird formatting: (de de+ Rest (let ((@Name @Args Doc . @Body) Rest) (macro (de @Name @Args ~'@Body)) (put @Name 'Doc Doc) @Name)) # there was a typo in my previous post
Then you can do: (de+ f (A) "docstring" A) Otherwise just after the function declaration you can do (put 'f 'docstr "docstring") On Tue, Apr 20, 2021, 07:30 Davide BERTOLOTTO <davide.bertolo...@gmail.com> wrote: > I don't know of any *Function global, but hey, it's lisp ;) you can do > your own 'de' like this, with a docstring clojure-style (after args) > > (de de+ Rest > (let ((@Name @Args Doc . @Body) Rest) (macro (de @Name > @Args ~'@Body)) (put @Name 'Doc Doc) > Name)) > > Maybe Alex has something more to add > > Regards, > Davide > > On Tue, Apr 20, 2021, 04:45 polifemo <brunofrancosala...@gmail.com> wrote: > >> Inspired by the way methods are defined, by just defining them and >> looking which class a method belongs to by looking into the global variable >> *Class, I'd like to have a similar mechanism for creating docstrings. >> >> My idea is something like this: >> ``` >> (de f (A) A) >> (mkdocstr "A test function that returns its argument evaluated") >> ``` >> >> where mkdocstr is defined like this: >> ``` >> (de mkdocstr (Docstr) >> (put *Function 'docstr Docstr) ) >> ``` >> >> This, of course, requires some global variable *Function that saves the >> last symbol defined by 'de. Is there such a variable? Or is there a way to >> change 'de to write to that variable? >> >