aspl-lang/aspl

aspl: add a builtin exponentiation/power operator

Open

#25 opened on Mar 9, 2026

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C (6 forks)auto 404
enhancementgood first issuehelp wanted

Repository metrics

Stars
 (30 stars)
PR merge metrics
 (PR metrics pending)

Description

Feature idea

I initially left this out intentionally and thought placing a pow function in the math stdlib module would be enough. But there are problems with this (bad readability, requires importing the whole module, pow is typed with doubles), so introducing a designated power operator would probably be a good addition to ASPL.

Possible solutions/implementations

I suggest using the ** symbol for the power operator as it is used by various other languages as well.

Regarding types, I think the operator should output integral types (integer and long) when applied to two integral arguments; otherwise, it should return a float/double, but I'm not sure about that yet.

Alternatives considered

As mentioned above, the current canonical way of exponentiating numbers in ASPL is by using the pow function from the math stdlib module, but there a several reasons why this is not sufficient (see above). However, I'm currently not sure what to do with the pow function in the future once we have implemented the exponention operator.

The ^ symbol is currently used for the logical XOR as well as the enum flag bitwise XOR, so we cannot also use it for exponentiation.

Additional context

No response

Contributing guidelines

  • I agree to follow this project's contributing guidelines

Contributor guide