<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'Some question about Chapter.14 (How to execute string)' | Pragmatic Forums</title>
    <link>http://fora.pragprog.com/forums/27/topics/384</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>Some question about Chapter.14 (How to execute string) posted by Alain O'Dea @ Wed, 07 May 2008 01:33:05 -0000</title>
      <description>&lt;p&gt;&lt;strong&gt;lib_misc:string2value/1&lt;/strong&gt; is implemented as follows:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;string2value(Str) -&amp;gt;
    {ok, Tokens, _} = erl_scan:string(Str ++ "."),
    {ok, Exprs} = erl_parse:parse_exprs(Tokens),
    Bindings = erl_eval:new_bindings(),
    {value, Value, _} = erl_eval:exprs(Exprs, Bindings),
    Value.&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;I could not find a direct equivalent to Python&amp;#8217;s &lt;strong&gt;exec&lt;/strong&gt; statement in the modules shipped with Erlang &lt;span class="caps"&gt;OTP R12B&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;The entire set of example code for Programming Erlang is available for download here:&lt;br /&gt;&lt;a href="http://www.pragprog.com/titles/jaerlang/source_code"&gt;http://www.pragprog.com/titles/jaerlang/source_code&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 07 May 2008 01:33:05 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:27:384:2744</guid>
      <author>Alain O'Dea</author>
      <link>http://fora.pragprog.com/forums/27/topics/384</link>
    </item>
    <item>
      <title>Some question about Chapter.14 (How to execute string) posted by Yuichi Ito @ Fri, 25 Apr 2008 07:27:36 -0000</title>
      <description>&lt;p&gt;Hello.&lt;br /&gt;I want to execute the code of Chap14 &amp;#8220;start_nano_server()&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;But there is no function &amp;#8220;lib_misc:string2value(String)&amp;#8221;.&lt;br /&gt;So, I checked this book&amp;#8217;s index(reference?), and searched in Google.&lt;br /&gt;But couldn&amp;#8217;t find both.&lt;/p&gt;


	&lt;p&gt;this function acts like this&lt;br /&gt;&amp;gt; lib_misc:string2value(&amp;#8220;list_to_tuple([2+3*4,10+20])&amp;#8221;).&lt;br /&gt;{14,30}&lt;/p&gt;


	&lt;p&gt;How do I create this function?&lt;br /&gt;Or, is there a function which execute string like Python&amp;#8217;s &amp;#8220;exec Statement&amp;#8221;?&lt;/p&gt;


	&lt;p&gt;Thsnks&lt;br /&gt;(I&amp;#8217;m using Japanese editon, so there may be little difference in English edition)&lt;/p&gt;</description>
      <pubDate>Fri, 25 Apr 2008 07:27:36 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:27:384:2635</guid>
      <author>Yuichi Ito</author>
      <link>http://fora.pragprog.com/forums/27/topics/384</link>
    </item>
  </channel>
</rss>
