Where can I find documentation on the "use" directive in Scheme? - scheme

I am using Chicken Scheme and I am attempting to understand the meaning of (use abcd) and how it differs from (require-extension abcd). The Chicken website does not seem to have sufficient information to clarify and a web search provided no helpful information. If Anyone would point Me in the direction of such documentation, I would greatly appreciate it. Thanks.

Here's the documentation:
use
[syntax] (use ID ...)
use is just a shorter alias for require-extension.
And just in case:
require-extension
[syntax] (require-extension ID ...)
This is equivalent to (require-library ID ...) but performs an implicit import,
if necessary. Since version 4.4.0, ID may also be an import specification (using
rename, only, except or prefix).
This implementation of require-extension is compliant with SRFI-55 (see the
SRFI-55 document for more information).

Related

How to record scheme session in a file?

I'm trying to record my session while writing some scheme code, But I don't know which is the correct code to record my session while doing some expression.
R5RS
R5RS has an optional procedure transcript-on that takes a file name and it will output the interaction until transcript-off` is called. (Thanks #molbdnilo for pointing this out in a comment)
R6RS and R7RS
This is not supported in the report. Even (scheme-report-environment 5)‌ is specified not to contain the optional procedures load, interaction-environment, transcript-on, transcript-off, and char-ready?.
Implementation lock-ins
The individual implementations might have such features included and if you just need it for you chosen implementation you must read its documentation to find it. I guess this is for tooling rather than production code so using implementation specific features isn't as bad as using non scheme standard forms.
roll your own
You can make your own repl that does what you want with the file output of you chosing that would be the same across all implementations.

What is C(argument) in documentation

Recently I have been reviewing a lot of Ansible modules(code) and I have come across some with this strange nomenclature in the documentation section when referring to arguments such as the examples (F5 modules) below:
specified, the default of C(round-robin) will be used
or this
If this value is an IP address, and the C(type) is C(tcp) (the
default),
then a C(port) number must be specified.
What is the C and is it required when documenting your code? As I said not all of the modules have in them.
I just found this in ansible.docs-1.7.pdf1), page 545:
The description, and notes fields support formatting with some
special macros.
These formatting functions are U(), M(), I(), and C() for URL,
module, italic, and constant-width respectively. It is suggested to
use C() for file and option names, and I() when referencing
parameters; module names should be specifies as M(module).
1) This seems to be somewhat dated, but should still be valid. The same can also be found in the latest online documentation.

Strings in the middle of lisp S-exp?

I have Googled a handful of things such as "lisp documentation strings", "lisp comments", and a few others and I cant find anything that specifically addresses this.
I see a lot of code (especially in CL and elisp) that looks like
(defvar test 1
"This is a quoted string and it says things"
)
Where I would normally do
; This is a comment
(defvar test 1)
Which is preferred? Do each serve a different purpose? Thanks!
Many objects in Common Lisp can have a documentation string, that can be retrieved with the generic function documentation and set with the generic function (setf documentation). According to the specification:
Documentation strings are made available for debugging purposes. Conforming programs are permitted to use documentation strings when they are present, but should not depend for their correct behavior on the presence of those documentation strings. An implementation is permitted to discard documentation strings at any time for implementation-defined reasons.
So the first case allows the definition of a variable together with its documentation string, that can be used to store at run-time, if the implementation permits so, information useful for documentation and debugging purposes, either used through the IDE, or directly, through a form like:
(documentation 'test 'variable)
The second case, instead, is just a comment inside a source file, useful only for human consumption, and it is completely ignored by the reader/compiler of the system.
Development environments will use these documentation features. For example GNU Emacs / SLIME:
Move the text cursor onto the symbol test.
Type c-c c-d c-d (Describe Symbol).
Now SLIME displays a buffer with the following content:
COMMON-LISP-USER::TEST
[symbol]
TEST names a special variable:
Value: 1
Documentation:
This is a quoted string and it says things
A simple comment in the source code won't enable this form of development environment integration and documentation lookup.
I saw your tag included scheme and elisp as well. In CL and Elisp always use docstrings. They are used by documentation systems in their languages. Scheme does not have that feature so you will have to continue using comments to document functions.
Did't you try to see hyperspec for defvar?
defvar takes an optional argument - document string, and this is what are you talking about.
Documentation specified this way can be acessed throug documentation:
CL-USER> (defvar *a* "A variable" "A docstring")
*A*
CL-USER> (documentation '*a* 'variable)
"A docstring"

How to get all bindings visible in current scope in Scheme48 (or any Scheme for that matter)

I'm doing some stuff with Scheme48/Scsh. What I find rather inconvenient is the lack of name completion (analogous to Guile's (ice-9 readline) or Racket's Xrepl). But before Scheme48 gets completion (if it ever does) I'd like to be able to do some introspection by hand. My question is how can you get the list of all identifiers defined/visible in the current context. If I understand correctly, Scheme has one unified namespace for variables and functions (unlike Common Lisp), so this would supply information about both. Any suggestions will be appreciated.
You want to introspect environments. I am not sure that Scheme 48 has such a feature, but its module system is perhaps the way to do it.
You might want the (interaction-environment) of R7RS. I guess that S48 is not R7RS compliant.

Where to find Scheme library functions?

Is there a reference website to look up syntax for Scheme library function like http://www.cplusplus.com/reference/?
I'm looking for syntax of fold, but google gave me nothing :(
Thanks,
fold is from SRFI 1. Many functions have good documentation if you know where it "comes from".
Also, since you're using Racket (as mentioned in your previous questions), you should check out the Racket documentation. It has a very nice search facility. (Also, you might like to know about Racket's foldl, which is identical to SRFI 1's fold.)

Resources