Skip to content
Snippets Groups Projects
Commit 48ad5c61 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add a short description of high-level types

parent 95fa0f99
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
......@@ -1607,6 +1607,46 @@ the output is
*** High-level types<<high-level-types>>
Aside from the basic type described in the previous section, ~pugs~ also
deals with "high-level" types. This term is more to understand as
"non-basic types". The ~pugs~ language is not object oriented to keep it
simple.
To fix ideas let use give a few high-level type of data. These can be
for instance meshes (the ~mesh~ type), output streams (the ~ostream~
type), boundary descriptors (~boundary~), quadrature formula
(~quadrature~), discrete functions (~Vh~),...
One can already see that the complexity of these types may vary a lot.
The main difference between these types and basic types is that,
high-level types are not available in directly the language but they
are loaded on demand (using the ~import~ keyword in the preamble of the
script).
The second difference is that data of these type are *constant*. More
precisely, the content of high-level variables can be replaced by a
new one *but* it cannot be modified. For this reason, the following
operators can never be applied to variables of this kind
| forbidden operators | description |
|---------------------+-----------------------------|
| ~++~ | pre/post increment operator |
| ~--~ | pre/post decrement operator |
| ~+=~ | assignment by sum |
| ~-=~ | assignment by difference |
| ~*=~ | assignment by product |
| ~/=~ | assignment by quotient |
We conclude by stating that if access operator ~[]~ can eventually be
overloaded for high-level types, it is quite difficult and should be
done with care. It is not recommended.
Finally, the last difference lies in the fact that high-level types
use shallow copy and not value copy as it is the case for basic
types. This is transparent to the user and provides the intuitive
(similar) behavior since data of high-level variables are constant. To
illustrate this, let us consider the following example.
*** TODO Lists
*** TODO Tuples types
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment