Quantcast
Channel: MaplePrimes - Questions and Posts tagged with read
Viewing all articles
Browse latest Browse all 43

problem using $include in module. export declaration unexpected outside module

$
0
0

This seems like a serious limitation of Maple module, unless I am missing something.

I am trying to refactor one of my module, putting some code in separate .mpl file, say B.mpl,  and then do, from the main module

   $include  "B.mpl"; 

 But Maple complain now that, since B.mpl has export in it, that I can't do that. 

But the code inside B.mpl works fine if I copy it back and paste it inside the module, in the same location where the $include  "B.mpl";  is

Here is an example. (Since I can't use $include  "B.mpl";  in worksheet, Maple does not like it, I replaced it in this example by read "B.mpl";

(btw, both the syntax  module A()   and A:=module() seem to be equivalent), the problem shows up with either form)

I also tried with ";" and witout ";" at the end of the $include , it still gives same error.

 

restart;

currentdir("....."); #set directory to where the folder is


module A()

read "B.mpl";

 export foo:=proc()
  0;
 end proc;
end module;

Where the file B.mpl is

export boo:=proc()
return 0;
end proc; 

How is one supposed to refactor long file to separate files if can't leave export on those proc's?  

If I put everything in one .mpl file, it works

module A()

#read "B.mpl";  

export boo:=proc()  #this proc was in B.mpl
return 0;
end proc; 

 export foo:=proc()
  0;
 end proc;
end module;

I did more testing, and found that this seems to be an issue in Maple 2020.2. Because I just tried the same thing in Maple 2019 and it worked there ! i.e. no error.

Any one knows what is going on? 

Maple 2020.2, Physics 884.   Windows 10.

Here is screen shot. Same code. Works OK in Maple 2019.2 but gives error in 2020.2

 

 

 


Viewing all articles
Browse latest Browse all 43

Trending Articles