<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Get the module of a export</title>
    <link>http://www.mapleprimes.com/questions/119997-Get-The-Module-Of-A-Export</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Sun, 14 Jun 2026 00:47:27 GMT</lastBuildDate>
    <pubDate>Sun, 14 Jun 2026 00:47:27 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Get the module of a export</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Get the module of a export</title>
      <link>http://www.mapleprimes.com/questions/119997-Get-The-Module-Of-A-Export</link>
    </image>
    <item>
      <title>A method that works for named modules</title>
      <link>http://www.mapleprimes.com/questions/119997-Get-The-Module-Of-A-Export?ref=Feed:MaplePrimes:Get the module of a export:Comments#answer120072</link>
      <itunes:summary>&lt;p&gt;In general, there is no method that I know of that will allow you to get the name of the module to which an arbitrary module export belongs.&amp;nbsp; However, there is a method that works for &lt;em&gt;named &lt;/em&gt;modules.&amp;nbsp;&amp;nbsp; Normally, a module does not have a (sort of) canonical name, other than any names to which it may be assigned.&amp;nbsp; However, by using an alternate module definition syntax, you can create a named module, which does have a "canonical" name.&amp;nbsp;&amp;nbsp; In this case, the canonical name is stored in the attributes of each of its exports.&lt;/p&gt;
&lt;p&gt;For example, creating a module in the usual way, we see that there are no attributes on the export a.&lt;/p&gt;
&lt;pre&gt;&amp;gt; m := module() export a; end:&lt;br&gt;&amp;gt; attributes( m:-a );&lt;/pre&gt;
&lt;p&gt;However, by creating a named module, we get the following:&lt;/p&gt;
&lt;pre&gt;&amp;gt; module m1() export a; end:&lt;br&gt;&amp;gt; attributes( m1:-a );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modulename = m1&lt;/pre&gt;
&lt;p&gt;Note the different syntax.&amp;nbsp; There is no assignment statement used in the creation of m1.&amp;nbsp; We simply evaluate the module definition with the name m1 after the keyword module as shown, and the assignment takes place behind the scenes, as it were.&amp;nbsp; (Note also that the name m1 is now protected.)&lt;/p&gt;
&lt;p&gt;Notice that the export m1:-a has the attribute modulename = m1.&amp;nbsp;&amp;nbsp; Using this information, we can write a simple routine to pick up the name of a named module.&lt;/p&gt;
&lt;pre&gt;&amp;gt; GetModuleName := proc( e )&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; local a, pos;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a := [attributes]( e );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; `if`( membertype( 'identical'( 'modulename' ) = 'name', a, 'pos' ), &lt;br&gt;                a[ pos ], NULL )&lt;br&gt; end proc:&lt;br&gt;&amp;gt; GetModuleName( m:-a );&lt;br&gt;&amp;gt; GetModuleName( m1:-a );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m1&lt;/pre&gt;
&lt;p&gt;I should point out that there is another important, and much more common way in which a module may acquire a name.&amp;nbsp; Whenever a module is saved to a repository (.mla file), it is given a name, that being the one under which it was saved.&amp;nbsp; In this way, all the modules that are shipped with Maple as part of the standard library are, in fact, named modules.&lt;/p&gt;
&lt;pre&gt;&amp;gt; GetModuleName( LinearAlgebra:-Determinant );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LinearAlgebra&lt;/pre&gt;
&lt;p&gt;Here, the export Determinant of the LinearAlgebra package has stored among its attributes the equation modulename = LinearAlgebra because LinearAlgebra is a named module by virtue of having been saved to a repository.&lt;/p&gt;
&lt;p&gt;In general, named modules should be used with some care.&amp;nbsp; For example, suppose that you assigned the named module m1 above to the name u, and then saved it in a repository using the name u, via a call such as savelib(u);.&amp;nbsp; It would be saved just fine, and you could refer to it in other Maple sessions using the name u.&amp;nbsp; However, the procedure GetModuleName defined above would return the original name m1 given to it when it was created.&amp;nbsp; This is because it is the original name m1 that is stored in the attributes of the exports.&lt;/p&gt;
&lt;pre&gt;&amp;gt; attributes( u:-a );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modulename = m1&lt;/pre&gt;
&lt;p&gt;There is, therefore, much potential for confusion with named modules.&lt;/p&gt;
&lt;!--break--&gt;</itunes:summary>
      <description>&lt;p&gt;In general, there is no method that I know of that will allow you to get the name of the module to which an arbitrary module export belongs.&amp;nbsp; However, there is a method that works for &lt;em&gt;named &lt;/em&gt;modules.&amp;nbsp;&amp;nbsp; Normally, a module does not have a (sort of) canonical name, other than any names to which it may be assigned.&amp;nbsp; However, by using an alternate module definition syntax, you can create a named module, which does have a "canonical" name.&amp;nbsp;&amp;nbsp; In this case, the canonical name is stored in the attributes of each of its exports.&lt;/p&gt;
&lt;p&gt;For example, creating a module in the usual way, we see that there are no attributes on the export a.&lt;/p&gt;
&lt;pre&gt;&amp;gt; m := module() export a; end:&lt;br&gt;&amp;gt; attributes( m:-a );&lt;/pre&gt;
&lt;p&gt;However, by creating a named module, we get the following:&lt;/p&gt;
&lt;pre&gt;&amp;gt; module m1() export a; end:&lt;br&gt;&amp;gt; attributes( m1:-a );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modulename = m1&lt;/pre&gt;
&lt;p&gt;Note the different syntax.&amp;nbsp; There is no assignment statement used in the creation of m1.&amp;nbsp; We simply evaluate the module definition with the name m1 after the keyword module as shown, and the assignment takes place behind the scenes, as it were.&amp;nbsp; (Note also that the name m1 is now protected.)&lt;/p&gt;
&lt;p&gt;Notice that the export m1:-a has the attribute modulename = m1.&amp;nbsp;&amp;nbsp; Using this information, we can write a simple routine to pick up the name of a named module.&lt;/p&gt;
&lt;pre&gt;&amp;gt; GetModuleName := proc( e )&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; local a, pos;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a := [attributes]( e );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; `if`( membertype( 'identical'( 'modulename' ) = 'name', a, 'pos' ), &lt;br&gt;                a[ pos ], NULL )&lt;br&gt; end proc:&lt;br&gt;&amp;gt; GetModuleName( m:-a );&lt;br&gt;&amp;gt; GetModuleName( m1:-a );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m1&lt;/pre&gt;
&lt;p&gt;I should point out that there is another important, and much more common way in which a module may acquire a name.&amp;nbsp; Whenever a module is saved to a repository (.mla file), it is given a name, that being the one under which it was saved.&amp;nbsp; In this way, all the modules that are shipped with Maple as part of the standard library are, in fact, named modules.&lt;/p&gt;
&lt;pre&gt;&amp;gt; GetModuleName( LinearAlgebra:-Determinant );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LinearAlgebra&lt;/pre&gt;
&lt;p&gt;Here, the export Determinant of the LinearAlgebra package has stored among its attributes the equation modulename = LinearAlgebra because LinearAlgebra is a named module by virtue of having been saved to a repository.&lt;/p&gt;
&lt;p&gt;In general, named modules should be used with some care.&amp;nbsp; For example, suppose that you assigned the named module m1 above to the name u, and then saved it in a repository using the name u, via a call such as savelib(u);.&amp;nbsp; It would be saved just fine, and you could refer to it in other Maple sessions using the name u.&amp;nbsp; However, the procedure GetModuleName defined above would return the original name m1 given to it when it was created.&amp;nbsp; This is because it is the original name m1 that is stored in the attributes of the exports.&lt;/p&gt;
&lt;pre&gt;&amp;gt; attributes( u:-a );&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modulename = m1&lt;/pre&gt;
&lt;p&gt;There is, therefore, much potential for confusion with named modules.&lt;/p&gt;
&lt;!--break--&gt;</description>
      <guid>120072</guid>
      <pubDate>Fri, 20 May 2011 03:02:43 Z</pubDate>
      <itunes:author>james1482</itunes:author>
      <author>james1482</author>
    </item>
  </channel>
</rss>