Regarding literals and loop indices modes / programming friction
Jose E. Marchesi
jemarch@gnu.org
Sun Jan 25 22:35:03 GMT 2026
>> Regarding the SIN monadic op mentioned by Mohammad-Reza:
>>
>> On Sun, Jan 25, 2026 at 4:07 PM Mohammad-Reza Nabipoor
>> <mnabipoor@gnu.org> wrote:
>>>
>>> Another way is to define SIN/COS as monadic operators, and then enjoying the overloading
>>> capabilities:
>>>
>>> ```algol68
>>> op SIN = (real r) real: sin (r),
>>> SIN = (long real lr) long real: long_sin (lr),
>>> COS = (real r) real: cos (r),
>>> COS = (long real lr) long real: long_cos (lr);
>>> ```
>>
>> Is there any reason why this would not be done for all such
>> (reasonable) mathematical functions (at the language level)?
>>
>> I mean, could not our present day "sin" be renamed to "sin_real", and
>> then create a monadic operator named "sin" which would allow all
>> variants of real modes? It appears it would provide broad benefits to
>> the user.
>
> Standard `sin' and `cos' operators are just regular operators, and they
> are provided for the following modes:
>
> real -> real
> long real -> long real
>
> So I don't really understand why you would need to define any of the
> operators above, nor the need for long_sin or long_cos.
>
> Well, other than it looks like I forgot to implement `long real'
> versions of `arccos', `arcsin', `arctan', `cos', `exp', `ln', `sin',
> `sqrt', and `tan' ^^
>
> Will do it this week. These standard routines (and pi, sqrt, exp, ln)
> are always supposed to be available for all supported sizes of real.
Ok I am hallucinating today.
These are procedures, not operators.
And they _are_ implemented: sin, longsin, longlongsin, cos, longcos, ...
>
> Remember that widening is not active in firm contexts, so `int' and
> `real' are not firmly related and you can define separated overloaded
> operators for these.
>
>>
>> Probably a silly question. But I am curious.
More information about the Algol68
mailing list