diff --git a/doc/userdoc.org b/doc/userdoc.org index e7fe896122d842402bad67c9118fdc22b4e9d8ee..e06853aecdb62e60a340120ecef5483f6d236806 100644 --- a/doc/userdoc.org +++ b/doc/userdoc.org @@ -721,7 +721,7 @@ view. One just have to keep in mind that, as it will be depicted after, high-level variables *are not mutable*: their values can be *replaced* by a new ones but *cannot be modified*. -*** Implicit type conversions +*** Implicit type conversions<<implicit-conversion>> In order to avoid ambiguities, in ~pugs~, there is *no implicit* conversion in general. @@ -738,6 +738,21 @@ This will be detailed in section [[functions]] and [[tuples]] This means that all affectation, unary and binary operators are defined explicitly for supported types. +Here is a table of implicit type conversion *when allowed*. + +| expected type | convertible types | +|---------------+------------------------------------------------| +| ~N~ | ~B~, ~Z~ | +| ~Z~ | ~B~, ~N~ | +| ~R~ | ~B~, ~N~, ~Z~ | +| ~R^1~ | ~B~, ~N~, ~Z~, ~R~, ~0~ (special value) | +| ~R^2~ | ~0~ (special value) | +| ~R^3~ | ~0~ (special value) | +| ~R^1x1~ | ~B~, ~N~, ~Z~, ~R~, ~0~ (special value) | +| ~R^2x2~ | ~0~ (special value) | +| ~R^3x3~ | ~0~ (special value) | +| ~string~ | ~B~, ~N~, ~Z~, ~R~, ~R^1~, ~R^2~, ~R^3~, ~R^1x1~, ~R^2x2~, ~R^3x3~ | + *** Operators **** Affectation operators @@ -1750,8 +1765,9 @@ data of a *unique* and *simple* type (one cannot use compound types to define tuples). The list of values given to the tuple must be *implicitly* convertible -to the type of tuple elements. There is no ambiguity, the implicit -conversions follow the rules of operator ~=~. +to the type of tuple elements (see the conversion table in section +[[implicit-conversion]]). There is no ambiguity, the implicit conversions +follow the rules of operator ~=~. **** Tuple declaration and affectation @@ -2097,7 +2113,12 @@ modified value is not a variable of the language itself but the internal random seed itself. #+END_note -*** TODO Implicit type conversion for parameters and returned values +*** Implicit type conversion for parameters and returned values + +As already said, in general, there is no implicit type conversion in +the ~pugs~ language. The only exceptions are when initializing tuples +(see [[tuples]]) and for functions arguments and returned values. See the +conversion table in section [[implicit-conversion]]. *** User-defined functions<<user-defined-functions>>