Jump to content
Excelsior Forums
Sign in to follow this  
kaztkc

Exporting an enumerate type from a local module

Recommended Posts

Hi, I'm having a trouble in exporting an enumerate type from a local module.

This is the simplified version of my code. I want to export SortMode type

defined in line 10, but it causes an error at the end of local module.

Grammatically it's correct, is it not?

    1 MODULE test;

    2

    3 FROM InOut IMPORT WriteString;

    4

    5 MODULE Comparison;

    6  IMPORT WriteString;

    7  EXPORT SortModes, InOrder, InOrderIni;

    8

    9 TYPE

  10  SortModes = (SortByCode, IgnoreCase, DecimalVal);

  11  CmpProcs = PROCEDURE (VAR CHAR, VAR CHAR): BOOLEAN;

  12

  13 VAR

  14  InOrder: CmpProcs;

  15  Mode: SortModes;

  16

  17 PROCEDURE InOrderAsc(VAR ch0, ch1: CHAR): BOOLEAN;

  18 BEGIN

  19  RETURN FALSE END InOrderAsc;

  20

  21 PROCEDURE InOrderAscIg(VAR ch0, ch1: CHAR): BOOLEAN;

  22 BEGIN

  23  RETURN FALSE END InOrderAscIg;

  24

  25 PROCEDURE InOrderAscNum(VAR ch0, ch1: CHAR): BOOLEAN;

  26 BEGIN

  27  RETURN FALSE END InOrderAscNum;

  28

  29 PROCEDURE InOrderIni(Mode: SortModes; EndStr: CHAR; BeginCol: CARDINAL);

  30 BEGIN

  31  IF Mode = IgnoreCase THEN

  32    InOrder := InOrderAscIg; WriteString("IgnoreCase selected.")

  33  ELSIF Mode = DecimalVal THEN

  34    InOrder := InOrderAscNum; WriteString("DecimalVal selected.")

  35  ELSE

  36    InOrder := InOrderAsc; WriteString("SortByCode selected.")

  37  END

  38 END InOrderIni;

  39

  40 END Comparison;

  41

  42 (* main module *)

  43

  44 BEGIN (*main*)

  45  InOrderIni(IgnoreCase, 0C, 0);

  46 END test.

XDS Modula-2 v2.40 [x86, v1.50] - build 10.05.2005

Compiling "test.mod"

* [test.mod 40.15 E022]

* identifier "SortByCode" was already defined at test.mod[40.15]

END Comparison$;

errors  1, no warnings, lines  46, time  0.02

Share this post


Link to post
Share on other sites

I made the case simpler, so inspect this one.

    1 MODULE test;

    2

    3 FROM InOut IMPORT WriteString;

    4

    5 MODULE Local;

    6  IMPORT WriteString;

    7  EXPORT XYZ, Select;

    8

    9 TYPE

  10  XYZ= (x, y, z);

  11 PROCEDURE Select(which: XYZ);

  12 BEGIN

  13  IF which = x THEN

  14    WriteString("x selected.")

  15  ELSIF which = y THEN

  16    WriteString("y selected.")

  17  ELSE

  18    WriteString("z selected.")

  19  END

  20 END Select;

  21 END Local;

  22

  23 BEGIN (*main module*)

  24  Select(z)

  25 END test.

XDS Modula-2 v2.40 [x86, v1.50] - build 10.05.2005

Compiling "test.mod"

* [test.mod 21.10 E022]

* identifier "x" was already defined at test.mod[21.10]

END Local$;

errors  1, no warnings, lines  25, time  0.00

Share this post


Link to post
Share on other sites

That seems to be a potential problem with the compiler.  (Just to check, I compiled the code with the p2 compiler, with the substitution of STextIO for InOut, and no problem.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×