<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rlucas.net: The Next Generation &#187; propaedeutics</title>
	<atom:link href="http://blog.rlucas.net/tag/propaedeutics/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rlucas.net</link>
	<description>...fighting entropy one financing round at a time</description>
	<lastBuildDate>Sat, 04 Sep 2010 01:45:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The &#8220;user&#8221; virtual file / workspace in Prolog.</title>
		<link>http://blog.rlucas.net/uncategorized/the-user-virtual-file-workspace-in-prolog/</link>
		<comments>http://blog.rlucas.net/uncategorized/the-user-virtual-file-workspace-in-prolog/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 19:35:00 +0000</pubDate>
		<dc:creator>rlucas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prolog]]></category>
		<category><![CDATA[propaedeutics]]></category>

		<guid isPermaLink="false">http://blog.rlucas.net/?p=397</guid>
		<description><![CDATA[When you&#8217;re first learning about Prolog, sometimes you&#8217;ll read books or tutorials that show you typing in &#8220;clauses,&#8221; and then immediately thereafter typing a &#8220;query.&#8221; If you use a visual or browser-based Prolog implementation, you&#8217;ll discover that there are two &#8220;modes&#8221; (my term), one for the input of the program / database, and one for [...]]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re first learning about Prolog, sometimes you&#8217;ll read books or tutorials that show you typing in &#8220;clauses,&#8221; and then immediately thereafter typing a &#8220;query.&#8221;  If you use a visual or browser-based Prolog implementation, you&#8217;ll discover that there are two &#8220;modes&#8221; (my term), one for the input of the program / database, and one for querying.  The query form is denoted by the prompt &#8220;?-&#8221; as in:<br />
<code><br />
?- my_query_(Variable).</code></p>
<p>To me, it was somewhat confusing as to why and how I had to keep separate my program from my queries, since I was used to REPL-type interactive programming (e.g. irb for Ruby).</p>
<p>Later, in reading the SWI-Prolog manual, I saw reference to this odd snippet in the &#8220;<a href="http://www.swi-prolog.org/pldoc/doc_for?object=section%282%2c%20%274.27%27%2c%20swi%28%27%2fdoc%2fManual%2fextendarith.html%27%29%29">Adding Arithmetic Functions</a>&#8221; section:</p>
<p><code>?- [user].</p>
<p>:- other_stuff(x).</code><br />
&#8230;</p>
<p>It appeared that [user] was changing the mode from query-mode to program-mode, and allowing me to define new predicates.</p>
<p>Well, close.  It turns out the way to think about this (can&#8217;t seem to find it in the SWI-Prolog manual) is that the square-bracket notation is the &#8220;load file&#8221; shortcut, and Prolog comes with a virtual file known as &#8220;user.&#8221;  When you query:</p>
<p><code>?- [user].</code></p>
<p>and then go on to get:</p>
<p><code>|:</code></p>
<p>as your new prompt, you&#8217;re loading the &#8220;user&#8221; file which is like opening a handle on STDIN.  (Not precisely, but close enough.)  You can then type your program entries, /but you must terminate them with EOF/ (ctrl-D).</p>
<p>This bit of prerequisite knowledge would have saved me a lot of puzzlement and trial-and-error.  A shame that Prolog, despite a nearly 40-year history of continuous use and usefulness, has such a high propaedeutic load.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rlucas.net/uncategorized/the-user-virtual-file-workspace-in-prolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->