🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.oberon
2 messages
2 total messages Started by Michael Griebling Sat, 20 Apr 1996 20:28
Oberon-2 Inconsistencies
#1350
Author: Michael Griebling
Date: Sat, 20 Apr 1996 20:28
62 lines
2506 bytes
The members of the OOC project would like to start a discussion to resolve
some issues in the area of compiler-related legalities.  We have found that
various compilers treat the following topics differently either because the
language reference doesn't cover the issue or there may be some interpretation
differences.

These items are presented in no particular order:

1) INC/DEC

Is the following statement legal?
  VAR s: SHORTINT; i: INTEGER;
  ...
  INC (i, s)
Looking into the report I'd say yes, but some ETH compilers say no.
[I haven't checked this in the last few years, though.]

Some compilers also allow the following:

  VAR s: SomePtr;

  INC (SYSTEM.VAL(LONGINT, s), 4);

Our reading of the Oberon report says this is illegal.  Is the VAL
just a type-casting mechanism or is it to be treated as a function?
If the latter, why is the above syntax accepted by some ETH compilers?

----------------------------------------------------------------------

2) Order of declaration of type-bound procedures

Is the following sequence of tb-procs legal?
  TYPE R1 = RECORD END; R2 = RECORD (R1) END;
  ...
  PROCEDURE (VAR r: R2) P;
    END P;

  PROCEDURE (VAR r: R1) P;
    END P;
The report doesn't say anything about this, and some ETH compilers say
no.  Matters get more complicated if the formal parameters of R1.P and
R2.P differ (in this case it _is_ an error).
[I haven't checked this at all, I think Juergen told me about it.]

----------------------------------------------------------------------

3) The infamous WITH

Should a procedure's parameter change it's type in the procedure's
formal parameter list if it's guarded by WITH?
[I had mail from Templ on this.  He said this peculiar behaviour is
covered by the report and quoted the relevant section to me.  I'm not
convinced, though.  Lost the mail, too :-( ]

----------------------------------------------------------------------

4) Is type testing/guarding a NIL pointer legal?

Oakwood says no, but this topic creeps up now and then in the news.


-- From the OOC Development Group
Re: Oberon-2 Inconsistencies
#1353
Author: Bill Leary
Date: Sun, 21 Apr 1996 15:46
37 lines
1976 bytes
My reference is 'Programming in Oberon.'
I don't have a copy of the report handy.
When I _did_ I don't recall any differences, but of course, your
memory may vary (probably in sync with facts).

----Quoting Michael Griebling----
> Is the following statement legal?
> VAR s: SHORTINT; i: INTEGER;
> INC (i, s)
I'd say yes. A.10.2 Table A.3 only specifies "integer type"

> VAR s: SomePtr;
> INC (SYSTEM.VAL(LONGINT, s), 4);
Offhand, I'd say no. A.12 Table A4, where this function is listed, is
titled "Function Procedures."  Thus, it's a function and can't
be an LVAL.  OTOH, I gather it's purpose is to let you treat arbetrary
sections of memory as any type you please (or need to), so I'd then
have to say, well, maybe.  From the syntax I'd always assumed that the T
in "VAL(T,x)" was a defined, rather than integral, type.

> Is type testing/guarding a NIL pointer legal?
I'd say no, but I can see the alternate argument.  To me, you've
typed the pointer, but there's no object if the pointer is NIL, and
the whole purpose of the type guard is to find check what the object
is NOW.  If it's NIL it can't be any type your checking against.
The question I see open is, should it refuse to compile, crash the
program, or simply fail the type guard check?  Given my druthers, I
think I'd prefer to see it do the third in real programs, but since
there are other ways to handle all this (ie: check for a NIL pointer)
I think I'd prefer to have the compiler tell me I've got a problem.

	- Bill

-- 
+----------------------------------------------------------------
| William J. Leary Jr.
| Paralyn Associates
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads