[Oberon] Type conversion.

Joerg joerg.straube at iaeth.ch
Sun Jul 2 17:51:37 CEST 2023


Hi

I can‘t answer the question, why the author of this source code uses „remPort“ with an explicit conversion and „locPort“ with the implicit conversion, the compiler generates.

br
Jörg

> Am 02.07.2023 um 14:00 schrieb Michael Schierl <schierlm at gmx.de>:
> 
> Hello,
> 
> 
>> Am 02.07.2023 um 07:14 schrieb peter at easthope.ca:
>> ETH Oberon (2019) Language Report
>> p. 56,
>> 12.1.1. Conversions
>> LONG(x) ... DEPRECATED
> 
> Page 21:
> 
> Where there is no implicit compatibility between types, they can be
> converted with an explicit conversion. The type name itself can be used
> for a type conversion.
> 
> 
>> 
>> oberon/source/Unix.Oberon.NetSystem.Mod
>>    PROCEDURE OpenConnection* ( VAR conn: Connection; locPort: UNSIGNED16; remIP: IPAdr; remPort: UNSIGNED16;
>>                                                    VAR res: SIGNED16 );
>>    VAR r: SIGNED32;
>>    BEGIN
>>        IF remPort = anyport THEN remIP := anyIP END;
>>        NEW( conn );
>>        conn.Open( locPort, remIP, LONG(remPort) MOD 10000H, r );
>>        IF r = TCP.Ok THEN res := done  ELSE  res := error  END
>>    END OpenConnection;
>> 
>> If LONG is removed, conn.Open won't agree on the type of the 3rd
>> parameter. Is there another way to convert a type?  The declaration of
>> Open also needs a change?
> 
> 
> conn.Open( locPort, remIP, UNSIGNED32(remPort) MOD 10000H, r );
> 
> 
> Regards,
> 
> 
> Michael
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon


More information about the Oberon mailing list