INT cannot be coerced to LONG REAL in a strong-UNIT

chris hermansen clhermansen@gmail.com
Fri Jun 20 22:02:33 GMT 2025


Thanks so much, Jose!

On Fri, Jun 20, 2025 at 2:55 PM Jose E. Marchesi <jemarch@gnu.org> wrote:

>
> Hello Chris.
>
> > Good day,
> >
> > I'm running into what seems to be an error to me, based on my still-rusty
> > Algol 68 coercion fu.
> >
> > I have this expression:
> >
> > long real a0 = ABS "0";
> >
> > and ga68 gives me this error:
> >
> > error: INT cannot be coerced to LONG REAL in a strong-UNIT
> >
> > That doesn't seem correct to me; as far as I know, INT can be widened to
> > REAL and REAL to LONG REAL in a strong context.
> >
> > I must be missing something but not sure what...
>
> The widening of real to long real is a Genie extension and not standard
> Algol 68.  There is no widening coercion from reals to reals, nor from
> ints to ints.  Only from int to real of the same size, from real to
> complex of the same size, from bits to row of booleans and from bytes to
> row of chars.
>
> The _of the same size_ restriction is expressed in the grammar via
> consistent substitution, like in 6.5.1.a:
>
>   a) widened to{b,61A} SIZETY real FORM :
>        MEEK{61C} SIZETY integral FORM.
>

Very good to know this.  I see Marcel's text  in his manual 6.5.3 Widening:

a68g implements next widenings


where he describes what I had thought was normal Algol 68 behaviour.

>
> This seems to be a common misconception.  Recently I had to correct the
> Wikipedia article on this regard.
>
> You need to use the leng operator to go from real to long real.
>

As I recall I have often mixed up "long" as  LONGETY and "leng" as the
LENGTHEN operator.

A big pile of rusty bits under my keyboard and chair on the floor,
accumulating over the last few days.

Again thanks!


-- 
Chris Hermansen · clhermansen "at" gmail "dot" com

C'est ma façon de parler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/algol68/attachments/20250620/6eedf6ff/attachment.htm>


More information about the Algol68 mailing list