GNU Pascal Homepage - gpc - gpc-announce - gpc-de - gpc-doc
Diese Seite auf deutsch

Mail #12379

Back to main page of archive

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  

From: Peter N Lewis
Subject: Forward defined types (and object
Date: 7 Jul 2005, 19:55:20

At 12:32 +0200 7/7/05, Frank Heckenbach wrote:
>Peter N Lewis wrote:
>
>  > >Peter N Lewis wrote:
>>  >  > CW takes the approach that any unknown type identifier it sees in a
>>  >>  type definition is pointer sized (a pointer or object) and must be
>>  >  > defined by the end of the type block.
>
>This would be wrong, as pointer targets can (according to standard
>Pascal and all other dialects) be of any type and may be
>forward-referenced, e.g. in this example, b is probably not
>pointer-sized, but it must work:
>
>program Foo;
>
>type
>   a = ^b;
>   b = array [1 .. 1000] of Integer;

CW handles this as well.  So it handles the two cases, an unknown 
identifier, and forward pointer references (as in, an unknown 
identifier after ^)

The handling of unknown identifiers is for the other cases (other 
than ^unknown).

>Actually, I just tried to figure out what BP does. It seems to be
>buggy. `{$T+}' is supposed to enforce strict type-checking with the
>address operator (@), but in this case is seems to allow the wrong
>assignment, and reject the right one. Anyway, bar really seems to be
>a pointer to a reference, so it would not help us here.

I'm not sure about BP, but I know CW often requires the @ before a 
procedure name for an assignment to a procedural variable to remote 
the ambiguity of whether to call it or not - and then introduces the 
new ambiguity of whether it is a procedural pointer or a pointer to a 
procedure pointer.  Ie, in CW:

function doit( a: Integer ): Integer;
begin
   return 1;
end;
type proc = function ( a: Integer ) : Integer;
var a: proc;
begin
   a := @doit;
   WriteLn( a( 10 ) ); // prints 1
end;

Perhaps BP does something equally weird.

>  > >It requires the `class' keyword. There is a problem, that `class' keyword
>>  >is (ATM) not accepted in Mac Pascal mode. It would be easy to implement
>>  >syntax with `object' as an alternate keword,
>
>As Gale wrote, the Mac Pascal syntax seems to be `object; forward;'.
>So if you can add this without conflicts, this would be preferable,
>I think.

Any (or all) of the different syntax is fine by me.

>  > >but than we would have to decide
>>  >what to do if `object' is used in a forward declaration in one mode, but
>>  >the proper declaration uses different mode.
>
>This should be an error IMHO. Why should we allow such useless
>obscurities?

Agreed.  Indeed, I would think it would be an error to forward 
declare (or define after a forward declare) any non-reference object.

Enjoy,
    Peter.

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  


Replies

Author Subject Date
Frank Heckenbach Forward defined types (and object 8 Jul 2005, 12:01:38

In reply to

Author Subject Date
Waldek Hebisch Forward defined types (and object references) 6 Jul 2005, 20:41:10
Peter N Lewis Forward defined types (and object references) 7 Jul 2005, 10:21:41
Frank Heckenbach Forward defined types (and object 7 Jul 2005, 12:32:35

Back to main page of archive


Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.

Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.


This page was created by Crystal 0.999 (Linux 2.4.27/i686).