• Assignment to record variable parameter

    From clive.thomas@gmail.com@21:1/5 to August Karlstrom on Tue Dec 11 23:06:45 2018
    On Monday, 30 January 2017 15:35:01 UTC+2, August Karlstrom wrote:
    Assuming that T is a record type, is this valid Oberon code?

    PROCEDURE P(VAR x: T);
    VAR y: T;
    BEGIN
    x := y
    END P

    If yes, should the program trap if the actual parameter x has a type
    which is a proper extension of T?


    -- August

    Hi August,
    Just for information - in my Oberon compiler, I know from experience that the example code will compile fine, but tends to give a type error at runtime when the assign occurs, especially with complex record variables. I am not sure why this is, I haven'
    t yet had the time or energy to debug the generated machine code to check why the type tags don't match (it is not entirely trivial to debug with record variables, it becomes quite a complex exercise).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From August Karlstrom@21:1/5 to clive.thomas@gmail.com on Wed Dec 12 18:49:06 2018
    On 2018-12-12 08:06, clive.thomas@gmail.com wrote:
    On Monday, 30 January 2017 15:35:01 UTC+2, August Karlstrom wrote:
    PROCEDURE P(VAR x: T);
    VAR y: T;
    BEGIN
    x := y
    END P

    Just for information - in my Oberon compiler, I know from experience that the example code will compile fine, but tends to give a type error at runtime when the assign occurs, especially with complex record variables. I am not sure why this is, I
    haven't yet had the time or energy to debug the generated machine code to check why the type tags don't match (it is not entirely trivial to debug with record variables, it becomes quite a complex exercise).


    According to my (current) understanding, the example should compile but
    trap at run-time if x is a proper extension of T.


    -- August

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)