[m-users.] Best way to implement constants ?

Julien Fischer jfischer at opturion.com
Fri Aug 18 19:37:54 AEST 2023


On Fri, 18 Aug 2023, Volker Wysk wrote:

> Am Freitag, dem 18.08.2023 um 10:45 +0200 schrieb Volker Wysk:
>> Hi, Sean
>>
>> Why don't you just use the "/" operator from the float library?
>
> I mean, constants like "1 / 2.75" will sure be evaluated at compile time.

1 / 2.75 is a type error in Mercury, it will evaluate to an error at
compile time. ;-)

At -O3 and above the Mercury compiler will (generally) evaluate a
variety of operations (see compiler/const_prop.m for details).
Float division is included in those operations

> And even if not, it's just a division, nothing expensive.

Relatively speaking, division *is* expensive.

Julien.


More information about the users mailing list