Migrating MW objects definitions

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Migrating MW objects definitions

fpanasiti@tiscali.it
I'm trying to migrate MW OO code to FPC. I'm in trouble with this piece of
MW code:

type
myObjectA = object
.....
lObj: myObjectB;
...
end;

type
myObjectB = object
...
lObj: myObjectA
...
end;

Essentially when the compiler tries to deal with myObjectA, it says that
'myObjectB is not defined'.

Am I doing something wrong, or is it something not supported by FPC?

Francesco

__________________________________________________________________
TISCALI ADSL
Solo con Tiscali Adsl navighi senza limiti e telefoni senza canone
Telecom a partire da 19,95 Euro/mese.
Attivala subito, I PRIMI DUE MESI SONO GRATIS! CLICCA QUI:
http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Peter Vreman
> I'm trying to migrate MW OO code to FPC. I'm in trouble with this piece of
> MW code:
>
> type
> myObjectA = object
> .....
> lObj: myObjectB;
> ...
> end;
>
> type
> myObjectB = object
> ...
> lObj: myObjectA
> ...
> end;
>
> Essentially when the compiler tries to deal with myObjectA, it says that
> 'myObjectB is not defined'.
>
> Am I doing something wrong, or is it something not supported by FPC?

If it works with MW, but fails with FPC it is not supported. Please log it
as a bug with a short example.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Jonas Maebe-2
In reply to this post by fpanasiti@tiscali.it

On 6 okt 2005, at 14:40, [hidden email] wrote:

> I'm trying to migrate MW OO code to FPC. I'm in trouble with this  
> piece of
> MW code:
>
> type
> myObjectA = object
> .....
> lObj: myObjectB;
> ...
> end;
>
> type
> myObjectB = object
> ...
> lObj: myObjectA
> ...
> end;
>
> Essentially when the compiler tries to deal with myObjectA, it says  
> that
> 'myObjectB is not defined'.
>
> Am I doing something wrong, or is it something not supported by FPC?

You have to use a forward declaration:

type
   MyObjectB = object;

   myObjectA = object
     .....
     lObj: myObjectB;
     ...
   end;

   myObjectB = object
     ...
     lObj: myObjectA
     ...
   end;

Notes:

a) forward declaration of MacPascal-style objects was not supported  
in our initial implementation due to a bug
b) the forward declaration and the full declaration of a type must be  
present in the same type-block (which is not the case in your example  
above, even if you would add a forward declaration, since there you  
start a new type-block for each declaration)


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re[2]: Migrating MW objects definitions

Ivan Shikhalev

-----Original Message-----
From: Jonas Maebe <[hidden email]>

> You have to use a forward declaration:
>
[skip]

AFAIK, this is impossible for static objects (object-types) as record-types too. It is needed to use class-types or pointers to object-types.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: Migrating MW objects definitions

Jonas Maebe-2

On 6 okt 2005, at 17:16, Ivan Shikhalev wrote:

>> You have to use a forward declaration:
>
> [skip]
>
> AFAIK, this is impossible for static objects (object-types) as  
> record-types too. It is needed to use class-types or pointers to  
> object-types.

We are talking about MacPas mode. MacPas objects are similar to  
classes in Delphi and are just pointers internally.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

fpanasiti@tiscali.it
In reply to this post by Jonas Maebe-2
>-- Messaggio Originale --
>From: Jonas Maebe <[hidden email]>
>Subject: Re: [fpc-pascal] Migrating MW objects definitions
>Date: Thu, 6 Oct 2005 15:01:56 +0200
>To: FPC-Pascal users discussions <[hidden email]>
>Reply-To: FPC-Pascal users discussions <[hidden email]>
>
>
>
>On 6 okt 2005, at 14:40, [hidden email] wrote:
>
>> I'm trying to migrate MW OO code to FPC. I'm in trouble with this
>> piece of
>> MW code:
>>
>> type
>> myObjectA = object
>> .....
>> lObj: myObjectB;
>> ...
>> end;
>>
>> type
>> myObjectB = object
>> ...
>> lObj: myObjectA
>> ...
>> end;
>>
>> Essentially when the compiler tries to deal with myObjectA, it says
>> that
>> 'myObjectB is not defined'.
>>
>> Am I doing something wrong, or is it something not supported by FPC?
>
>You have to use a forward declaration:
>
>type
>   MyObjectB = object;
>
>   myObjectA = object
>     .....
>     lObj: myObjectB;
>     ...
>   end;
>
>   myObjectB = object
>     ...
>     lObj: myObjectA
>     ...
>   end;
>
>Notes:
>
>a) forward declaration of MacPascal-style objects was not supported
>in our initial implementation due to a bug
>b) the forward declaration and the full declaration of a type must be
>present in the same type-block (which is not the case in your example
>above, even if you would add a forward declaration, since there you
>start a new type-block for each declaration)
>
>
>Jonas

Got the point, but there's still something wrong as I've tried the following
code but the parser claims for an identifier instead  ';' at the third line:
(I'm using FPC 2.0.0: could it matter?)
program TestObjects;
                type
                        myObjectB = object;
                       
                        myObjectA = object
                                index: longint;
                                lObj: myObjectB;
                                procedure SayHello;
                        end;

                        myObjectB = object
                                index: longint;
                                lObj: myObjectA;
                                procedure SayHello;
                        end;
........

francesco
_______________________________________________
>fpc-pascal maillist  -  [hidden email]
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal


__________________________________________________________________
TISCALI ADSL
Solo con Tiscali Adsl navighi senza limiti e telefoni senza canone
Telecom a partire da 19,95 Euro/mese.
Attivala subito, I PRIMI DUE MESI SONO GRATIS! CLICCA QUI:
http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Jonas Maebe-2

On 6 okt 2005, at 19:25, [hidden email] wrote:

> Got the point, but there's still something wrong as I've tried the  
> following
> code but the parser claims for an identifier instead  ';' at the  
> third line:
> (I'm using FPC 2.0.0: could it matter?)

Yes, support for MacPas style objects is only implemented in 2.1.x


Jonas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

fpanasiti@tiscali.it

>-- Messaggio Originale --
>From: Jonas Maebe <[hidden email]>
>Subject: Re: [fpc-pascal] Migrating MW objects definitions
>Date: Thu, 6 Oct 2005 19:28:07 +0200
>To: FPC-Pascal users discussions <[hidden email]>
>Reply-To: FPC-Pascal users discussions <[hidden email]>
>
>
>
>On 6 okt 2005, at 19:25, [hidden email] wrote:
>
>> Got the point, but there's still something wrong as I've tried the
>> following
>> code but the parser claims for an identifier instead  ';' at the
>> third line:
>> (I'm using FPC 2.0.0: could it matter?)
>
>Yes, support for MacPas style objects is only implemented in 2.1.x
>
>
>Jonas
>
I tried the 2.1.1 but it doesn't work yet, even I get different error messages
(i.e. 'duplicate identifier myObjectB' and 'forward type not resolved myObjectB').

Francesco

__________________________________________________________________
TISCALI ADSL
Solo con Tiscali Adsl navighi senza limiti e telefoni senza canone
Telecom a partire da 19,95 Euro/mese.
Attivala subito, I PRIMI DUE MESI SONO GRATIS! CLICCA QUI:
http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Jonas Maebe-2

On 7 okt 2005, at 14:23, [hidden email] wrote:

> I tried the 2.1.1 but it doesn't work yet, even I get different  
> error messages
> (i.e. 'duplicate identifier myObjectB' and 'forward type not  
> resolved myObjectB').

If you downloaded a snapshot, the reason is probably that it was  
added after that snapshot was created.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Migrating MW objects definitions

Lee, John
In reply to this post by fpanasiti@tiscali.it
FYI the latest Win32 v2.1.1 snapshot on ftp freepascal.org was last night & contains all source changes up to then. John

>
> If you downloaded a snapshot, the reason is probably that it was  
> added after that snapshot was created.
>
>


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Jonas Maebe-2

On 7 okt 2005, at 14:58, Lee, John wrote:

> FYI the latest Win32 v2.1.1 snapshot on ftp freepascal.org was last  
> night & contains all source changes up to then. John

That does not help for people using Mac OS X (which is where most  
MacPas users are).


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Migrating MW objects definitions

Lee, John
In reply to this post by fpanasiti@tiscali.it
Mmm agree... wasn't very helpful! J

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of
> Jonas Maebe
> Sent: 07 October 2005 14:05
> To: FPC-Pascal users discussions
> Subject: Re: [fpc-pascal] Migrating MW objects definitions
>
>
>
> On 7 okt 2005, at 14:58, Lee, John wrote:
>
> > FYI the latest Win32 v2.1.1 snapshot on ftp freepascal.org
> was last  
> > night & contains all source changes up to then. John
>
> That does not help for people using Mac OS X (which is where most  
> MacPas users are).
>
>
> Jonas
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

fpanasiti@tiscali.it
In reply to this post by Jonas Maebe-2

>-- Messaggio Originale --
>From: Jonas Maebe <[hidden email]>
>Subject: Re: [fpc-pascal] Migrating MW objects definitions
>Date: Fri, 7 Oct 2005 14:49:07 +0200
>To: FPC-Pascal users discussions <[hidden email]>
>Reply-To: FPC-Pascal users discussions <[hidden email]>
>
>
>
>On 7 okt 2005, at 14:23, [hidden email] wrote:
>
>> I tried the 2.1.1 but it doesn't work yet, even I get different
>> error messages
>> (i.e. 'duplicate identifier myObjectB' and 'forward type not
>> resolved myObjectB').
>
>If you downloaded a snapshot, the reason is probably that it was
>added after that snapshot was created.
>
>
>Jonas

I've downloaded the latest shapshots available on the web page (both June
and July version). Something which could matter: I couldn't use the standard
installer (aborted trying to install something called 'very big app'), thus
I inflated the archive + copy the contents using the terminal command lines.
Maybe something was missed that way round?
Francesco
>_______________________________________________
>fpc-pascal maillist  -  [hidden email]
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal


__________________________________________________________________
TISCALI ADSL
Solo con Tiscali Adsl navighi senza limiti e telefoni senza canone
Telecom a partire da 19,95 Euro/mese.
Attivala subito, I PRIMI DUE MESI SONO GRATIS! CLICCA QUI:
http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Vincent Snijders
In reply to this post by Jonas Maebe-2
Jonas Maebe wrote:

>
> On 7 okt 2005, at 14:23, [hidden email] wrote:
>
>> I tried the 2.1.1 but it doesn't work yet, even I get different  error
>> messages
>> (i.e. 'duplicate identifier myObjectB' and 'forward type not  resolved
>> myObjectB').
>
>
> If you downloaded a snapshot, the reason is probably that it was  added
> after that snapshot was created.
>

I build fpc 2.1.1 snapshots for lazarus (http://www.lazarus.freepascal.org).
You can download them from http://www.de.freepascal.org/lazarus or one
of its mirrors.

Warning: the snapshots are not tested before uploading.

Vincent.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Peter Vreman
In reply to this post by fpanasiti@tiscali.it
>>> I tried the 2.1.1 but it doesn't work yet, even I get different
>>> error messages
>>> (i.e. 'duplicate identifier myObjectB' and 'forward type not
>>> resolved myObjectB').
>>
>>If you downloaded a snapshot, the reason is probably that it was
>>added after that snapshot was created.
> I've downloaded the latest shapshots available on the web page (both June
> and July version). Something which could matter: I couldn't use the
> standard
> installer (aborted trying to install something called 'very big app'),
> thus
> I inflated the archive + copy the contents using the terminal command
> lines.
> Maybe something was missed that way round?

You need a current SVN checkout. The snapshots are too old



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Jonas Maebe-2
In reply to this post by fpanasiti@tiscali.it

On 7 okt 2005, at 15:19, [hidden email] wrote:

> I've downloaded the latest shapshots available on the web page  
> (both June
> and July version).

It was probably fixed later.

> Something which could matter: I couldn't use the standard
> installer (aborted trying to install something called 'very big  
> app'), thus
> I inflated the archive + copy the contents using the terminal  
> command lines.
> Maybe something was missed that way round?

No, probably not. But that installer was created via the command line  
with an apparently incomplete configuration, so packagemaker used  
some wrong defaults.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Migrating MW objects definitions

Jonas Maebe-2
In reply to this post by Peter Vreman

On 7 okt 2005, at 15:38, Peter Vreman wrote:

>> I've downloaded the latest shapshots available on the web page  
>> (both June
>> and July version). Something which could matter: I couldn't use the
>> standard
>> installer (aborted trying to install something called 'very big  
>> app'),
>> thus
>> I inflated the archive + copy the contents using the terminal command
>> lines.
>> Maybe something was missed that way round?
>
> You need a current SVN checkout. The snapshots are too old

The problem is that this support is only in 2.1.1, and debugging info  
in 2.1.1 is completely broken at this time (at least for classes). So  
you would have to checkout a revision from 2 weeks ago or so.

svn info on http://www.freepascal.org/wiki/index.php/SVN_Migration


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal