<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Encapsulated transformation of expression to compiled function</title>
    <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 08:33:06 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 08:33:06 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Encapsulated transformation of expression to compiled function</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Encapsulated transformation of expression to compiled function</title>
      <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression</link>
    </image>
    <item>
      <title>suggestion</title>
      <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression?ref=Feed:MaplePrimes:Encapsulated transformation of expression to compiled function:Comments#answer127975</link>
      <itunes:summary>&lt;p&gt;do not have Maple at my hands, now&lt;/p&gt;
&lt;p&gt;But the compiler can not handle integrals and as you wrote it&lt;br&gt;in lower case Maple would come up with incomplete gamma,&lt;br&gt;I think.&lt;/p&gt;
&lt;p&gt;However that may be a function, that the compiler does not know&lt;/p&gt;
&lt;p&gt;Anyway I just would try to give the function expression directly&lt;br&gt;and not by the steps you use, so I can see what happens (and&lt;br&gt;what are the domains for my inputs)&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;do not have Maple at my hands, now&lt;/p&gt;
&lt;p&gt;But the compiler can not handle integrals and as you wrote it&lt;br&gt;in lower case Maple would come up with incomplete gamma,&lt;br&gt;I think.&lt;/p&gt;
&lt;p&gt;However that may be a function, that the compiler does not know&lt;/p&gt;
&lt;p&gt;Anyway I just would try to give the function expression directly&lt;br&gt;and not by the steps you use, so I can see what happens (and&lt;br&gt;what are the domains for my inputs)&lt;/p&gt;</description>
      <guid>127975</guid>
      <pubDate>Tue, 22 Nov 2011 19:32:19 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>Remove evaln</title>
      <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression?ref=Feed:MaplePrimes:Encapsulated transformation of expression to compiled function:Comments#answer127979</link>
      <itunes:summary>&lt;p&gt;You will see one problem when you do&lt;/p&gt;
&lt;p&gt;f:=proc(expr::evaln)&lt;br&gt;unapply(expr,y::float,a::float, b::float)&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;f(H);&lt;/p&gt;
&lt;p&gt;f2:=proc(expr)&lt;br&gt;unapply(expr,y::float,a::float, b::float)&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;f2(H);&lt;/p&gt;
&lt;p&gt;So remove the type check expr::evaln.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As for the original question replace int() by evalf(Int()):&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;myint:= proc(u::float)::float;&lt;br&gt;evalf(Int(exp(x^6), x=0.0..u))&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;'createcomp' I don't quite understand. &lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You will see one problem when you do&lt;/p&gt;
&lt;p&gt;f:=proc(expr::evaln)&lt;br&gt;unapply(expr,y::float,a::float, b::float)&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;f(H);&lt;/p&gt;
&lt;p&gt;f2:=proc(expr)&lt;br&gt;unapply(expr,y::float,a::float, b::float)&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;f2(H);&lt;/p&gt;
&lt;p&gt;So remove the type check expr::evaln.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As for the original question replace int() by evalf(Int()):&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;myint:= proc(u::float)::float;&lt;br&gt;evalf(Int(exp(x^6), x=0.0..u))&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;'createcomp' I don't quite understand. &lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <guid>127979</guid>
      <pubDate>Tue, 22 Nov 2011 19:54:08 Z</pubDate>
      <itunes:author>Preben Alsholm</itunes:author>
      <author>Preben Alsholm</author>
    </item>
    <item>
      <title>Get rid of ::evaln</title>
      <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression?ref=Feed:MaplePrimes:Encapsulated transformation of expression to compiled function:Comments#answer127992</link>
      <itunes:summary>&lt;p&gt;I'll elaborate a little on good advice already given.&amp;nbsp; If you remove the ::evaln modifier in your definition of the procedure func_encaps it seems to work just fine.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;By adding ::evaln to the parameter specification in your definition of func_encaps you have caused that procedure to pass the name H to the unapply call within it.&amp;nbsp; This in turn produces a procedure (essentially) equivalent to&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;proc( y::float, a::float, b::float ) global H; return H end;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;which is almost certainly not what you intended.&amp;nbsp; This procedure can be compiled but, since the global name H does not evaluate to a numeric value at runtime, you get the error you see.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;It is almost always a bad idea to add ::evaln (or, likewise, ::uneval) to a procedure argument specification.&amp;nbsp; These modifiers force the procedure to use special evaluation rules, whcih are meant to be used only in unusual circumstances.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;James McCarron, Maplesoft&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;I'll elaborate a little on good advice already given.&amp;nbsp; If you remove the ::evaln modifier in your definition of the procedure func_encaps it seems to work just fine.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;By adding ::evaln to the parameter specification in your definition of func_encaps you have caused that procedure to pass the name H to the unapply call within it.&amp;nbsp; This in turn produces a procedure (essentially) equivalent to&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;proc( y::float, a::float, b::float ) global H; return H end;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;which is almost certainly not what you intended.&amp;nbsp; This procedure can be compiled but, since the global name H does not evaluate to a numeric value at runtime, you get the error you see.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;It is almost always a bad idea to add ::evaln (or, likewise, ::uneval) to a procedure argument specification.&amp;nbsp; These modifiers force the procedure to use special evaluation rules, whcih are meant to be used only in unusual circumstances.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;James McCarron, Maplesoft&lt;/p&gt;</description>
      <guid>127992</guid>
      <pubDate>Wed, 23 Nov 2011 01:58:56 Z</pubDate>
      <itunes:author>james1482</itunes:author>
      <author>james1482</author>
    </item>
    <item>
      <title>func_encaps</title>
      <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression?ref=Feed:MaplePrimes:Encapsulated transformation of expression to compiled function:Comments#answer128011</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression#comment128001"&gt;@icegood&lt;/a&gt; , ok, I have have not recognized it, sorry.&lt;/p&gt;
&lt;p&gt;I think the problem with your code is, how Maple understands&lt;br&gt;- the parameters a and b within the body&lt;br&gt;- the usage of the modifier, as james 1482 points out&lt;/p&gt;
&lt;p&gt;I guess the compiler treats a and b as symbols (=not declared&lt;br&gt;variables in a C code)&lt;/p&gt;
&lt;p&gt;Step-by-Step here would mean&lt;/p&gt;
&lt;p&gt;enc:= (...)&lt;br&gt;local p&lt;br&gt;p:= unapply(...)&lt;br&gt;# Compiler:-Compile # deactivate for debuging&lt;br&gt;end proc;&lt;/p&gt;
&lt;p&gt;Now t:= enc(H), and H something simple, say H:=y+a+b.&lt;/p&gt;
&lt;p&gt;What do you expect for t(Y,A,B) and what do you actually get?&lt;br&gt;And why?&lt;/p&gt;
&lt;p&gt;Only if you know that it makes sense to compile.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression#comment128001"&gt;@icegood&lt;/a&gt; , ok, I have have not recognized it, sorry.&lt;/p&gt;
&lt;p&gt;I think the problem with your code is, how Maple understands&lt;br&gt;- the parameters a and b within the body&lt;br&gt;- the usage of the modifier, as james 1482 points out&lt;/p&gt;
&lt;p&gt;I guess the compiler treats a and b as symbols (=not declared&lt;br&gt;variables in a C code)&lt;/p&gt;
&lt;p&gt;Step-by-Step here would mean&lt;/p&gt;
&lt;p&gt;enc:= (...)&lt;br&gt;local p&lt;br&gt;p:= unapply(...)&lt;br&gt;# Compiler:-Compile # deactivate for debuging&lt;br&gt;end proc;&lt;/p&gt;
&lt;p&gt;Now t:= enc(H), and H something simple, say H:=y+a+b.&lt;/p&gt;
&lt;p&gt;What do you expect for t(Y,A,B) and what do you actually get?&lt;br&gt;And why?&lt;/p&gt;
&lt;p&gt;Only if you know that it makes sense to compile.&lt;/p&gt;</description>
      <guid>128011</guid>
      <pubDate>Wed, 23 Nov 2011 14:26:26 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>for example</title>
      <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression?ref=Feed:MaplePrimes:Encapsulated transformation of expression to compiled function:Comments#answer128033</link>
      <itunes:summary>&lt;pre&gt;enc:=proc(expr)&lt;br&gt;# risky: assumes that y,a,b are THE indets of expr ...&lt;br&gt;local p;&lt;br&gt;p:= codegen[makeproc](expr, [y::numeric,a::numeric,b::numeric]); &lt;br&gt;#p:= codegen[prep2trans](p);&lt;br&gt;Compiler:-Compile(p, [y,a,b]);&lt;br&gt;end proc;&lt;/pre&gt;
&lt;pre&gt;H:= ((as in your example above))&lt;/pre&gt;
&lt;pre&gt;t:=enc(H);&lt;/pre&gt;
&lt;pre&gt;t(1.0,2,3);&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; 4.28730926684034230&lt;br&gt;&lt;br&gt;&lt;/pre&gt;</itunes:summary>
      <description>&lt;pre&gt;enc:=proc(expr)&lt;br&gt;# risky: assumes that y,a,b are THE indets of expr ...&lt;br&gt;local p;&lt;br&gt;p:= codegen[makeproc](expr, [y::numeric,a::numeric,b::numeric]); &lt;br&gt;#p:= codegen[prep2trans](p);&lt;br&gt;Compiler:-Compile(p, [y,a,b]);&lt;br&gt;end proc;&lt;/pre&gt;
&lt;pre&gt;H:= ((as in your example above))&lt;/pre&gt;
&lt;pre&gt;t:=enc(H);&lt;/pre&gt;
&lt;pre&gt;t(1.0,2,3);&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; 4.28730926684034230&lt;br&gt;&lt;br&gt;&lt;/pre&gt;</description>
      <guid>128033</guid>
      <pubDate>Thu, 24 Nov 2011 00:45:11 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>to axel</title>
      <link>http://www.mapleprimes.com/questions/127969-Encapsulated-Transformation-Of-Expression?ref=Feed:MaplePrimes:Encapsulated transformation of expression to compiled function:Comments#comment127980</link>
      <itunes:summary>&lt;p&gt;It really cannot thats why such calls should be encapsulated in fuctions (not in expressions thought unfortunately)&lt;/p&gt;
&lt;p&gt;For example this one works:&lt;/p&gt;
&lt;p&gt;myint:= proc(a);&lt;br&gt;return int(exp(x^6), x=0.0..a);&lt;br&gt;end proc:&lt;/p&gt;
&lt;p&gt;createcomp:=proc (f) local exprfunc::symbol;&lt;br&gt;return Compiler:-Compile(f);&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;zzz:=(y::float,a::float, b::float)-&amp;gt;myint(a): #intermediate encapsulation&lt;/p&gt;
&lt;p&gt;s:=createcomp(zzz);&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Warning, the function names {myint} are not recognized in the target language&lt;/p&gt;
&lt;p&gt;That what i can get! zzz compiled to external call of myint. While int directly will not even will be compiled because of syntax error (.. in arguments range for definite integral). But i don't need that actually.&amp;nbsp; The question is actually then how to divide expression into 'compilible' and noncompilible parts. &lt;br&gt;&lt;br&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;It really cannot thats why such calls should be encapsulated in fuctions (not in expressions thought unfortunately)&lt;/p&gt;
&lt;p&gt;For example this one works:&lt;/p&gt;
&lt;p&gt;myint:= proc(a);&lt;br&gt;return int(exp(x^6), x=0.0..a);&lt;br&gt;end proc:&lt;/p&gt;
&lt;p&gt;createcomp:=proc (f) local exprfunc::symbol;&lt;br&gt;return Compiler:-Compile(f);&lt;br&gt;end proc:&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;zzz:=(y::float,a::float, b::float)-&amp;gt;myint(a): #intermediate encapsulation&lt;/p&gt;
&lt;p&gt;s:=createcomp(zzz);&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Warning, the function names {myint} are not recognized in the target language&lt;/p&gt;
&lt;p&gt;That what i can get! zzz compiled to external call of myint. While int directly will not even will be compiled because of syntax error (.. in arguments range for definite integral). But i don't need that actually.&amp;nbsp; The question is actually then how to divide expression into 'compilible' and noncompilible parts. &lt;br&gt;&lt;br&gt;&lt;/p&gt;</description>
      <guid>127980</guid>
      <pubDate>Tue, 22 Nov 2011 20:14:02 Z</pubDate>
      <itunes:author>icegood</itunes:author>
      <author>icegood</author>
    </item>
  </channel>
</rss>