memgraph/src
Lovro Lugovic 017dec8c0e LCP: Refactor the type representation
Summary:
# Summary

## Concepts and terminology

A **namestring for <object>** is a Lisp string that names the C++ language element
`<object>` (such as a namespace, a variable, a class, etc.). Therefore we have a
"namestring for a namespace", a "namestring for a variable", etc.

A **designator for a namestring for <object>** is a Lisp object that denotes a
"namestring for <object>". These are symbols and strings themselves.

A **typestring** is a Lisp string that represents a C++ type, i.e. its
declaration.

A **typestring designator** is a Lisp object that denotes a typestring.

A typestring (and the corresponding C++ type) is said to be **supported** if it
can be parsed using `parse-cpp-type-declaration`. This concept is important and
should form the base of our design because we can't really hope to ever support
all of C++'s type declarations.

A typestring (and the corresponding C++ type) that is not supported is
**unsupported**.

A **processed typestring** is a typestring that is either fully qualified or
unqualified.

A C++ type is said to be **known** if LCP knows extra information about the type,
rather than just what kind of type it is, in which namespace it lives, etc. For
now, the only known types are those that are defined within LCP itself using
`define-class` & co.

A C++ type is **unknown** if it is not known.

**Typestring resolution** is the process of resolving a (processed) typestring
into an instance of `cpp-type` or `unsupported-cpp-type`.

**Resolving accessors** are accessors which perform typestring resolution.

## Changes

Explicitly introduce the concept of supported and known types. `cpp-type` models
supported types while `unsupported-cpp-type` models unsupported types.
Subclasses of `cpp-type` model known types. `general-cpp-type` is either a
`cpp-type` or an `unsupported-cpp-type`.

Add various type queries.

Fix `define-rpc`'s `:initarg` (remove it from the `cpp-member` struct).

Introduce namestrings and their designators in `names.lisp`.

Introduce typestrings and their designators.

Introduce **processed typestrings**. Our DSL's macros (`define-class` & co.)
convert all of the given typestrings into processed typestrings because we don't
attempt to support partially qualified names and relative name lookup yet. A
warning is signalled when a partially qualified name is treated as a fully
qualified name.

The slots of `cpp-type`, `cpp-class`, `cpp-member` and `cpp-capnp-opts` now
store processed typestrings which are lazily resolved into their corresponding
C++ types.

The only thing that instances of `unsupported-cpp-type` are good for is getting
the typestring that was used to construct them. Most of LCP's functions only
work with known C++ types, i.e. `cpp-type` instances. The only function so far
that works for both of them is `cpp-type-decl`.

Since "unsupportedness" is now explicitly part of LCP, client code is expected
to manually check whether a returned type is unsupported or not (or face
receiving an error otherwise), unless a function is documented to return only
`cpp-type` instances.

A similar thing goes for "knowness". Client code is expected to manually check
whether a returned type is known or not, unless a function is documented to
return only (instances of `cpp-type` subclasses) known types.

## TODO

Resolution still has to be done for the following slots of the
following structures:

-   `slk-opts`
    -   `save-args`
    -   `load-args`

-   `clone-opts`
    -   `args`
    -   `return-type`

Reviewers: teon.banek, mtomic

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1962
2019-05-10 16:18:31 +02:00
..
audit Migrate to C++17 2019-04-23 14:46:44 +02:00
auth Migrate to C++17 2019-04-23 14:46:44 +02:00
communication Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
data_structures Migrate to C++17 2019-04-23 14:46:44 +02:00
database Add DumpGenerator class 2019-05-10 15:57:37 +02:00
distributed Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
durability Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
glue Add syntax for managing data constraints 2019-02-25 14:31:29 +01:00
integrations Migrate to C++17 2019-04-23 14:46:44 +02:00
io Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
lisp LCP: Refactor the type representation 2019-05-10 16:18:31 +02:00
query LCP: Refactor the type representation 2019-05-10 16:18:31 +02:00
raft Fix low read throughput due to active waits 2019-05-09 16:28:39 +02:00
requests Implement kafka transform functionality 2018-07-19 12:52:25 +02:00
slk Migrate RPC to SLK 2019-05-06 14:27:57 +02:00
stats Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
storage Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
telemetry Migrate to C++17 2019-04-23 14:46:44 +02:00
transactions Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
utils Add nullptr check in LruList 2019-05-08 08:52:17 +02:00
CMakeLists.txt Add explicit common LCP target 2019-05-10 11:14:23 +02:00
config.hpp Migrate to C++17 2019-04-23 14:46:44 +02:00
memgraph_distributed.cpp Move distributed query stuff to new folder 2019-04-24 09:34:53 +02:00
memgraph_ha.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
memgraph_init.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
memgraph_init.hpp Migrate to C++17 2019-04-23 14:46:44 +02:00
memgraph.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
version.hpp.in Add version.hpp.in and display it on '--version' flag 2017-09-27 09:04:44 +02:00