What is the role of this word?

Hello,
I am very new to Julia.
Browsing Julia code implementation, I can see the following construct:

"""
    Some comments here ...
"""
Foo
...

My question is about this single word, here Foo, that is alone on a line. What is the role of it ? Is it a variable declaration with no type and no value ? Is it a type declaration (seems to be, but I expected struct or mutable struct or abstract type) ? Is it just documentation ? Or else ? What if we remove or change it, will it affect the execution ?

Here, a real example from a file string.jl :

"""
    String <: AbstractString

The default string type in Julia, used by e.g. string literals.

`String`s are immutable sequences of `Char`s. A `String` is stored internally as
a contiguous byte array, and while they are interpreted as being UTF-8 encoded,
they can be composed of any byte sequence. Use [`isvalid`](@ref) to validate
that the underlying byte sequence is valid as UTF-8.
"""
String

It’s just a target for the docstring. Sometimes people separate struct/function definitions and docstrings. Maybe String is defined in an unusual way somewhere else, for example in C code because it’s such a fundamental type, I haven’t checked.

6 Likes

That’s generally the case for Core types, you can check with parentmodule(_type).

1 Like