Closed codemanyak closed 7 months ago
PHP export doesn't handle typed constants correctly, either:
This falls into the same category as the first of the two aspects for Perl export and can be fixed together with it.
W.r.t. the handling of constants on Perl export in general: There is a Perl pragma to specify constants via use constant
. This would look like this for the example above:
use constant PI => 4 * atan(1);
This pragma has several drawbacks, though:
$
(if they are scalar) or @
(if they refer to lists/arrays) and they will not be interpolated to strings (expanded within string literals). This would have to be considered on transforming the diagram content and makes it significantly more complex.It is utterly difficult for the generator to decide the second point, i.e., whether the expression could be computed by the Perl compiler in advance. From syntax alone it is impossible. A built-in function like atan or atan2 can hardly be distinguished from a user-defined function that is simply just not available in Arranger on export.
Second aspect was fixed according to https://github.com/fesch/Structorizer.Desktop/issues/1156#issuecomment-2032501779 by introducing a new Perl-specific export option:
By activating it, the code will look as in the following example:
Without the option, the result will be:
[x] The Perl generator throws an expection on processing typed constant definitions:
[x] It does not properly address constancy of "untyped" constants: