Basic Questions

This is a discussion on Basic Questions within the modula forums in Programming Languages category; Hi, I am newbie to Modula2 trying to compile some legacy code that I am told worked with Top Speed Modula 2. Right now I am trying to use the XDS Compiler. I have two basic questions that I think may not be compiler specific (or may be not): 1. Does it matter if you break up a Procedure definition on to separate lines? i.e. is PROCEDURE vertab (VAR a,b,c:CARDINAL;VAR rowstart:ListPoint;VAR inf:File); And PROCEDURE vertab(VAR a,b,c:CARDINAL; VAR rowstart:ListPoint; VAR inf:File); The same?? I know in C and many other languages this does not matter. I am asking this question because ...

Go Back   Application Development Forum > Programming Languages > modula

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 04-05-2008, 05:04 PM
carmaski@yahoo.com
Guest
 
Default Basic Questions

Hi,

I am newbie to Modula2 trying to compile some legacy code that I am
told worked with Top Speed Modula 2. Right now I am trying to use the
XDS Compiler. I have two basic questions that I think may not be
compiler specific (or may be not):

1. Does it matter if you break up a Procedure definition on to
separate lines?

i.e. is

PROCEDURE vertab (VAR a,b,c:CARDINAL;VAR rowstart:ListPoint;VAR
inf:File);

And

PROCEDURE vertab(VAR a,b,c:CARDINAL;
VAR rowstart:ListPoint;
VAR inf:File);

The same?? I know in C and many other languages this does not matter.

I am asking this question because I have the Procedure definition in
the "*.def" file exactly the same as what I have in the "*.mod" file -
and it complains saying "procedure "vertab" does not match previous
definition" I don't know what the error is? I copied and pasted one to
the other just to make sure - still I get nothing.


2. Is there some module or package called "FIO" and how do I find out
what it contains?

I have a line like

FROM FIO IMPORT Create, Open, File, Close, WrStr, WrLn, WrLngCard,

In a "*.def" file but later in that file it tells me that "File" is
not defined.

Actually these errors may be related because this error comes from the
"VAR inf:File" in the procedure definition mentioned above.

Any ideas?

Thanks a lot for the help,
O.O.

Reply With Quote
  #2  
Old 04-06-2008, 05:22 AM
Marco van de Voort
Guest
 
Default Re: Basic Questions

On 2008-04-05, carmaski@yahoo.com <carmaski@yahoo.com> wrote:
> 1. Does it matter if you break up a Procedure definition on to
> separate lines?


No. The example you give is perfectly valid.

> I am asking this question because I have the Procedure definition in
> the "*.def" file exactly the same as what I have in the "*.mod" file -
> and it complains saying "procedure "vertab" does not match previous
> definition" I don't know what the error is? I copied and pasted one to
> the other just to make sure - still I get nothing.


Typically that means that one of the types are defined differently, either
in the .def _after_ the declaration or by one of the modules imported in the
implementation.

> 2. Is there some module or package called "FIO" and how do I find out
> what it contains?


I've no XDS experience, so I can't really answer this.

Maybe file is already defined in "IO" and not reexported in FIO?
Reply With Quote
  #3  
Old 04-06-2008, 05:40 AM
JP2R
Guest
 
Default Re: Basic Questions

On 6 avr, 11:22, Marco van de Voort <mar...@stack.nl> wrote:
> On 2008-04-05, carma...@yahoo.com <carma...@yahoo.com> wrote:
>
> > 1. Does it matter if you break up a Procedure definition on to
> > separate lines?

>
> No. The example you give is perfectly valid.
>
> > I am asking this question because I have the Procedure definition in
> > the "*.def" file exactly the same as what I have in the "*.mod" file -
> > and it complains saying "procedure "vertab" does not match previous
> > definition" I don't know what the error is? I copied and pasted one to
> > the other just to make sure - still I get nothing.

>
> Typically that means that one of the types are defined differently, either
> in the .def _after_ the declaration or by one of the modules imported in the
> implementation.
>
> > 2. Is there some module or package called "FIO" and how do I find out
> > what it contains?

>
> I've no XDS experience, so I can't really answer this.
>
> Maybe file is already defined in "IO" and not reexported in FIO?


Q1 - check if
1 - reference / value parameters declarations are the same (ie VAR
xx: type versus xx: type)
2 - if parameters names are the same (XDS doesn't like that)
Q2 - IO and FIO modules are modules of topspeed RTL with XDS you'll
probably need the TS compatybility pack to compile that downloadable
from XDS site.

Regards JPRR
Reply With Quote
  #4  
Old 04-06-2008, 06:46 AM
Marco van de Voort
Guest
 
Default Re: Basic Questions

On 2008-04-06, JP2R <jp.dezaire@orange.fr> wrote:
>
> Q1 - check if
> 1 - reference / value parameters declarations are the same (ie VAR
> xx: type versus xx: type)
> 2 - if parameters names are the same (XDS doesn't like that)



> Q2 - IO and FIO modules are modules of topspeed RTL with XDS you'll
> probably need the TS compatybility pack to compile that downloadable
> from XDS site.



OP:
>>> I have a line like


>>>FROM FIO IMPORT Create, Open, File, Close, WrStr, WrLn, WrLngCard,


>>>In a "*.def" file but later in that file it tells me that "File" is
>>>not defined.


Which leads me to conclude that FIO (and thus TS-pack) _is_ installed.
Reply With Quote
  #5  
Old 04-06-2008, 11:53 AM
O. Olson
Guest
 
Default Re: Basic Questions

On Apr 6, 3:22 am, Marco van de Voort <mar...@stack.nl> wrote:
> No. The example you give is perfectly valid.
>
> Typically that means that one of the types are defined differently, either
> in the .def _after_ the declaration or by one of the modules imported in the
> implementation.
>


Thanks Marco for clarifying this. This means I have a problem that is
complier specific that I would post to the XDS Forums.

I don't know what I am doing wrong - because I have copied the
Procedure declaration from the DEF File to the MOD File to ensure that
they are the same. I have also searched in each of the remaining file
to ensure that this procedure is not re-declared.

Thanks again for the post.
O.O.


Reply With Quote
  #6  
Old 04-06-2008, 11:59 AM
O. Olson
Guest
 
Default Re: Basic Questions

Thanks JPR2.
On Apr 6, 3:40 am, JP2R <jp.deza...@orange.fr> wrote:
>
> Q1 - check if
> 1 - reference / value parameters declarations are the same (ie VAR
> xx: type versus xx: type)


I have checked this i.e. copied the entire procedure declaration from
the DEF File to the MOD File. I have also removed all the other MOD
Files except the one that I want to start compiling from the directory
so that XDS would not be able to find them. (Their corresponding DEF
files are there though.) I then went through the DEF Files to ensure
that the Procedure was declared only once.

> 2 - if parameters names are the same (XDS doesn't like that)


I have copied and pasted this - so I think this should be the same.

> Q2 - IO and FIO modules are modules of topspeed RTL with XDS you'll
> probably need the TS compatybility pack to compile that downloadable
> from XDS site.
>


I have installed this Compatibility Pack. Before I did that - I got a
lot more errors than what I get now.


> Regards JPRR


Thanks for posting
O.O.
Reply With Quote
  #7  
Old 04-06-2008, 12:01 PM
O. Olson
Guest
 
Default Re: Basic Questions

On Apr 6, 4:46 am, Marco van de Voort <mar...@stack.nl> wrote:
> Which leads me to conclude that FIO (and thus TS-pack) _is_ installed.


Thanks for clarifying this. Yes, the TopSpeed Pack has been installed
- but if there is some magical way to enable it then I am not doing
that. Right now I am assuming that it gets enabled by default.
O.O.


Reply With Quote
  #8  
Old 04-06-2008, 01:28 PM
JP2R
Guest
 
Default Re: Basic Questions

On Apr 6, 5:59 pm, "O. Olson" <olson_...@yahoo.it> wrote:
> Thanks JPR2.
> On Apr 6, 3:40 am, JP2R <jp.deza...@orange.fr> wrote:
>
>
>
> > Q1 - check if
> > 1 - reference / value parameters declarations are the same (ie VAR
> > xx: type versus xx: type)

>
> I have checked this i.e. copied the entire procedure declaration from
> the DEF File to the MOD File. I have also removed all the other MOD
> Files except the one that I want to start compiling from the directory
> so that XDS would not be able to find them. (Their corresponding DEF
> files are there though.) I then went through the DEF Files to ensure
> that the Procedure was declared only once.
>
> > 2 - if parameters names are the same (XDS doesn't like that)

>
> I have copied and pasted this - so I think this should be the same.
>
> > Q2 - IO and FIO modules are modules of topspeed RTL with XDS you'll
> > probably need the TS compatybility pack to compile that downloadable
> > from XDS site.

>
> I have installed this Compatibility Pack. Before I did that - I got a
> lot more errors than what I get now.
>
> > Regards JPRR

>
> Thanks for posting
> O.O.


As Marco said you the 'PROCEDURE vertab...' exemple you gave is
perfectly valid.
Now ... just two sily questions, and you have probably checked that
before...
- Do you have another FIO | IO file on your hard disk (from an other
M2 compiler RTL)
- more likely to happen ... Procedure names of IO and FIO are the same
(WrLn, WrCard etc)
but parameters are NOT (in IO the File param is always implied)- maybe
check from which module TYPES identifiers are imported (File)
- TopSpeed was never an ISO compiler where XDS is,
JPRR

Reply With Quote
  #9  
Old 04-06-2008, 02:52 PM
Martin Whitaker
Guest
 
Default Re: Basic Questions

O. Olson wrote:
> On Apr 6, 3:22 am, Marco van de Voort <mar...@stack.nl> wrote:
>> No. The example you give is perfectly valid.
>>
>> Typically that means that one of the types are defined differently, either
>> in the .def _after_ the declaration or by one of the modules imported in the
>> implementation.
>>

>
> Thanks Marco for clarifying this. This means I have a problem that is
> complier specific that I would post to the XDS Forums.
>
> I don't know what I am doing wrong - because I have copied the
> Procedure declaration from the DEF File to the MOD File to ensure that
> they are the same. I have also searched in each of the remaining file
> to ensure that this procedure is not re-declared.
>

I think you've misunderstood Marco's point. Consider the following example:

DEFINITION MODULE x;

FROM y IMPORT File;

PROCEDURE DoSomething(f:File);

END x.

IMPLEMENTATION MODULE x;

FROM z IMPORT File;

PROCEDURE DoSomething(f:File);
BEGIN
END DoSomething;

END x.

The compiler would reject this unless y.File and z.File are aliases to the same
type. Be aware that Modula-2 matches types by name, not by structure, e.g. if
both y and z contained type definitions like:

TYPE File = RECORD
Name : ARRAY [0..127] OF CHAR;
Handle : CARDINAL
END;

y.File and z.File would be treated as different types, even though they are
structurally identical.

Hope this helps,

Martin
Reply With Quote
  #10  
Old 04-07-2008, 01:06 AM
O. Olson
Guest
 
Default Re: Basic Questions

On Apr 6, 12:52 pm, Martin Whitaker <spamt...@martin-whitaker.me.uk>
wrote:
> I think you've misunderstood Marco's point. Consider the following example:
>
> DEFINITION MODULE x;
>
> FROM y IMPORT File;
>
> PROCEDURE DoSomething(f:File);
>
> END x.
>
> IMPLEMENTATION MODULE x;
>
> FROM z IMPORT File;
>
> PROCEDURE DoSomething(f:File);
> BEGIN
> END DoSomething;
>
> END x.
>
> The compiler would reject this unless y.File and z.File are aliases to the same
> type. Be aware that Modula-2 matches types by name, not by structure, e.g. if
> both y and z contained type definitions like:
>
> TYPE File = RECORD
> Name : ARRAY [0..127] OF CHAR;
> Handle : CARDINAL
> END;
>
> y.File and z.File would be treated as different types, even though they are
> structurally identical.
>
> Hope this helps,
>
> Martin


Dear Martin,

Very, Very, Very, Good Point. This I did not expect - though I am yet
not sure if it is the error - but it is a good point to start out.

I have in the DEF File

FROM FIO IMPORT Create, Open, File, Close, WrStr, WrLn, WrLngCard,
WrCard;

And in the MOD file simply

IMPORT IO;

There is no where in the MOD File where it explicitly says IMPORT File
- like it does in the DEF.

This may explain why I might be getting an error in functions that
use" File" . While all the functions that give the error of not
matching the previous declaration have "File" as one of the parameters
- there are a few functions that use "File" - but yet do not give the
error.

I would check this out tomorrow.
Thanks for the tip.
O.O.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:18 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.