cjl@iuvax.UUCP (07/07/84)
Are low level type transfer functions limited to system primitive types ? How about user defined types, especially structured types ? My Hamburg version of Modula-2/VMS compiler won't accept the user defined types as the low level type transfer functions even when they occupy the same size of storage and have the same memory alignment boundary. As a result, I have to rely on the record variant to break the type checking for some structured data, e.g. system file buffers.
ags@pucc-i (Seaman) (07/08/84)
Any type is supposed to be usable as a transfer function. The following program should compile and run with no problems: MODULE TypeTransfer; FROM InOut IMPORT WriteCard; TYPE NumRec = RECORD First,Second : CARDINAL END; Descrip = RECORD Color : (Red,Blue,Yellow,Green); Flavor : (Vanilla,Chocolate,Strawberry) END; VAR Foo : NumRec; Bar : Descrip; BEGIN Bar.Color := Red; Bar.Flavor := Strawberry; Foo := NumRec(Bar); WriteCard(Foo.First,5); WriteCard(Foo.Second,5) END TypeTransfer. This runs under Volition Systems modula-2 and produces the output: 0 2 Other implementations may very well produce: 2 0 The program should run under any conforming implementation. -- Dave Seaman "My hovercraft is full of eels." ..!pur-ee!pucc-i:ags
ags@pucc-i (Seaman) (07/09/84)
In my previous note I assumed that TYPE Color = (Red,Blue,Yellow,Green); would occupy the same amount of storage as the type CARDINAL. I suppose this is not necessarily the case for all implementations. -- Dave Seaman "My hovercraft is full of eels." ..!pur-ee!pucc-i:ags
cjl@iuvax.UUCP (07/10/84)
Sorry. My program actually looks like this : MODULE cbr; PROCEDURE CBR(VAR P:INTEGER); BEGIN END CBR; TYPE t1 = INTEGER; VAR V:BITSET; BEGIN CBR(t1(V)) ^ reference not to a variable END cbr. Therefore my complaint comes from the call-by-reference parameter checking where type transfer function call is not accepted in the expression of actual var parameters! (* for Hamburger VAX/VMS Modula-2 compiler *) It would be more convenient if we are allowed to use low level type transfer function there. C.J.Lo, IUPUI (CSNET:cjl@Indiana@CSNet-Relay)
jacob@hpfclo.UUCP (07/11/84)
Nf-From: hpfclo!jacob Jul 17 11:13:00 1984 Come to think of it, the error message does seem to support your diagnosis. It is still possible, though, that you got a screwy error message. I wish I had a compiler here to check... Jacob Gore, same address.
jacob@hpfclo.UUCP (07/17/84)
Nf-From: hpfclo!jacob Jul 16 16:51:00 1984 I think you misdiagnosed your problem. As far as I know, types t1 (in your example) and INTEGER are not assignment compatible, at least when it comes to parameter passing. In other words, if you used "VAR P: t1" or "CBR(INTEGER(V))", the conversion should have worked. I've also used the Hamburg compiler. I don't recall having any problems with type conversion. I must admit though, that I also don't recall trying something like what you did in your example. Jacob Gore Currently at HP Fort Collins Systems Division Normally at Northwestern Univ. Comp. Sci. Res. Lab (and that's where the compiler is) ihnp4!hpfcla!jacob (I think)