<?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>Ryan Rampersad &#187; Errors</title>
	<atom:link href="http://blog.ryanrampersad.com/category/error/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ryanrampersad.com</link>
	<description>Thoughts, Ideas &#38; Opinions</description>
	<lastBuildDate>Thu, 17 May 2012 17:11:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-beta4-20825</generator>
		<item>
		<title>★ scheme: Inconsistency detected &#8211; MIT-Scheme Installation Mac OSX 10.7 Lion</title>
		<link>http://blog.ryanrampersad.com/2012/03/07/scheme-inconsistency-detected-mit-scheme-installation-mac-osx-10-7-lion/</link>
		<comments>http://blog.ryanrampersad.com/2012/03/07/scheme-inconsistency-detected-mit-scheme-installation-mac-osx-10-7-lion/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 04:49:28 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[scheme]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4413</guid>
		<description><![CDATA[SSH&#8217;ing through my MacBook Air to Ubuntu is great and all, but nothing beats running Scheme locally and natively. When I followed the instructions scattered around the Internet on Scheme installation, I would usually end up with this error. scheme: can’t find a readable default for option –band. searched for file all.com in these directories: [...]]]></description>
			<content:encoded><![CDATA[<p>SSH&#8217;ing through my MacBook Air to Ubuntu is great and all, but nothing beats running Scheme locally and natively. When I followed <a href="http://renevanbelzen.wordpress.com/2008/11/13/installing-mitgnu-scheme-on-mac-os-x-leopard/">the instructions</a> scattered <a href="https://wiki.umn.edu/CSCI1901/InstallingMITScheme">around the Internet</a> on Scheme installation, I would usually end up with this error.</p>
<blockquote><p>scheme: can’t find a readable default for option –band.<br />
searched for file all.com in these directories:<br />
/usr/lib/mit-scheme</p>
<p>Inconsistency detected.</p></blockquote>
<p>I tried nearly ever combination of symbolic linking from the <em>Applications</em> directory into <em>usr/lib</em> and I even created the infamous <em>usr/local/lib</em> despite its original non-existence.</p>
<p>One source suggested I set the path attribute in my profile. Since I had been copying willy-nilly the symbolic links to just about every location in /bin, /usr/bin/ and usr/lib, nothing made sense. I eliminated those references to start clean and simply updated my <em>.profile</em> with the following:</p>
<blockquote><p>export MITSCHEME_LIBRARY_PATH=/Applications/mit-scheme.app/Contents/Resources</p></blockquote>
<p>That will allow the Scheme executable to find the library when it runs. But how can you have it get recognized in the terminal? You actually do need a copy of the Scheme binary in there, or at least a symbolic link. So, just <code>cd</code> into the <em>/usr/bin</em> directory and then make the symlink.</p>
<p><blockquoute>sudo ln -s /Applications/mit-scheme.app/Contents/Resources/mit-scheme scheme</p></blockquote>
<p>If you try entering <em>scheme</em> into the terminal now, you&#8217;ll either get nothing (e.g. it&#8217;s not a proper bash command) or there&#8217;s inconsistency detected. What you&#8217;ll have to do is exit completely from the terminal. The paths have to update and restarting the terminal is the easy way to do it. After the restart though, you&#8217;ll see that <em>scheme</em> should work just fine now when called from the terminal on OSX.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2012/03/07/scheme-inconsistency-detected-mit-scheme-installation-mac-osx-10-7-lion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ Java: the left-hand side of an assignment must be a variable</title>
		<link>http://blog.ryanrampersad.com/2012/02/29/java-the-left-hand-side-of-an-assignment-must-be-a-variable/</link>
		<comments>http://blog.ryanrampersad.com/2012/02/29/java-the-left-hand-side-of-an-assignment-must-be-a-variable/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 17:48:03 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[assignment]]></category>
		<category><![CDATA[error]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4438</guid>
		<description><![CDATA[After programming in Scheme for months, going back to Java can cause some problems as you can imagine. I encountered this error a few days ago while writing just the simplest searching loop. It&#8217;s your typical searching for the largest value loop. It&#8217;s nothing special, but then again, it doesn&#8217;t work. At least the error [...]]]></description>
			<content:encoded><![CDATA[<p>After programming in Scheme for months, going back to Java can cause some problems as you can imagine. I encountered this error a few days ago while writing just the simplest searching loop.</p>
<pre class="brush: java; title: ; notranslate">
public static void main(String[] args) {
	int[] arr = new int[] {2804, 2374, 6382, 1899};
	
	int index = 0, largest = arr[0];
	for (int i = 1; i &lt; arr.length; i++) {
		(if largest &gt; arr[i]) {
			index = i;
			largest = arr[i];
		}
	}
}
</pre>
<p>It&#8217;s your <a href="http://blog.ryanrampersad.com/2011/05/11/ap-computer-science-2011-free-response-3/">typical searching for the largest value loop</a>. It&#8217;s nothing special, but then again, it doesn&#8217;t work.</p>
<p>At least the error message is logical. No, not really.</p>
<blockquote><p>the left-hand side of an assignment must be a variable</p></blockquote>
<p>By studying very carefully and fully realizing that I am still in <em>scheme</em> mode, I notice that there is a parenthesis before the if-statement instead after the <code>if</code> keyword itself. Had I been helping someone else with this code and they showed me that error message along with this, would I have known it was a misplaced parenthesis? No way. I&#8217;d eliminate one possibility at a time by removing each successive layer of expressions and assignments until it stopped. I might even go so far as to retype the entire thing. It&#8217;s subtle.</p>
<p>It also <a href="http://stackoverflow.com/questions/3639695/the-left-hand-side-of-an-assignment-must-be-a-variable-problem-with-charat">turns out that if you try to assign a value to a method</a>, you&#8217;ll cause this error too.</p>
<p class="signoff"><em>Happy language switching!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2012/02/29/java-the-left-hand-side-of-an-assignment-must-be-a-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ Java: syntax error on token &#8220;else&#8221;, delete this token</title>
		<link>http://blog.ryanrampersad.com/2012/02/22/java-syntax-error-on-token-else-delete-this-token/</link>
		<comments>http://blog.ryanrampersad.com/2012/02/22/java-syntax-error-on-token-else-delete-this-token/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 17:46:09 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[token]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4432</guid>
		<description><![CDATA[Before school ended, I donated some of my time to helping out the Intro to Java kids. In that class, I realized that when you tell beginning programmers &#8220;End each line with a semi-colon,&#8221; they think you really mean it. As in, every single line with actual code (e.g. not brackets) must end with a [...]]]></description>
			<content:encoded><![CDATA[<p>Before school ended, I donated some of my time to helping out the Intro to Java kids. In that class, I realized that when you tell beginning programmers <em>&#8220;End each line with a semi-colon,&#8221;</em> they think you really mean it. As in, every single line with actual code (e.g. not brackets) must end with a semi-colon. Well, it&#8217;s sad news but that is not true. Not every line needs a semi-colon.</p>
<p>Here&#8217;s an example. Look at this code. I dare you even to try running it. You&#8217;ll end up with an error.</p>
<pre class="brush: java; title: ; notranslate">
public static void main(String[] args) {
	int magic = 10;
	if (magic &lt; 20);
	{
		System.out.println(&quot;weak magic&quot;);
	} 
	else
	{
		System.out.println(&quot;strong magic&quot;);
	}
}	
</pre>
<p>The error is of course, uncommunicative of the true problem. Did you spot the error yet?</p>
<blockquote><p>syntax error on token &#8220;else&#8221;, delete this token</p></blockquote>
<p>The problem here isn&#8217;t the <code>else</code> or even the <code>if</code>. No, the problem is a <em>semi-colon</em>. Seriously. Take a look at the if-statement expression. The oddity comes about when you actually see the semi-colon attached to the end of it. And because the if-statement ended there, the <code>else</code> has no preceding pair so it has no choice but to error out.</p>
<p>This example is actually a clear cut case of putting a semi-colon after an if-statement expression. Imagine you didn&#8217;t have an error to remind you what you just did. You might just have a plain statement and proper following brackets.</p>
<pre class="brush: java; title: ; notranslate">
public static void main(String[] args) {
	int magic = 10;
	if (magic &lt; 20); {
		System.out.println(&quot;weak magic&quot;);
	}  
}
</pre>
<p>Without the <code>else</code> to throw an error message up, how easy would this be to spot? It&#8217;s tricky. What if your if-case was a rare edge case condition that you were hard pressed to demonstrate in testing but you theoretically knew it existed? You&#8217;d almost never know this wasn&#8217;t work until your nuclear reactor began to melt down.</p>
<p>The moral of story: kids will do what you tell them and mind you semi-colons at the end of constructs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2012/02/22/java-syntax-error-on-token-else-delete-this-token/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>★ Java: Duplicate local variable</title>
		<link>http://blog.ryanrampersad.com/2012/02/15/java-duplicate-local-variable/</link>
		<comments>http://blog.ryanrampersad.com/2012/02/15/java-duplicate-local-variable/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 17:44:19 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[duplication]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4430</guid>
		<description><![CDATA[It&#8217;s usually easy to catch errors in Java, either through the IDE you&#8217;re using or at compile time. Recently, I helped a friend taking a course in Java with an error he was getting in a lab he was working on. It mentioned something about a duplicate variable. Duplicate local variable Unfortunately, I didn&#8217;t grab [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s usually easy to catch errors in Java, either through the IDE you&#8217;re using or at compile time. Recently, I helped a friend taking a course in Java with an error he was getting in a lab he was working on. It mentioned something about a duplicate variable.</p>
<blockquote><p>Duplicate local variable</p></blockquote>
<p>Unfortunately, I didn&#8217;t grab his erring source code earlier, so I can&#8217;t give the true real world source. Nevertheless, my own crafted code should illuminate the problem sufficiently.</p>
<pre class="brush: java; title: ; notranslate">
public static void main(String[] args) {
	
	int magic = 10;
	if ( 10 &lt; 11 ) {
		int magic = 12;
		magic++;
	}
	
}
</pre>
<p>Imagine you had a variable declaration and initialization at the top of some method. Then later you attempt to create another variable with the same name as before, but inside of a construct like a <em>for loop</em> or <em>if</em>. Unwittingly, you have attempted to redeclare an already declared variable.</p>
<p>Why doesn&#8217;t the IDE or compiler know that it&#8217;s a syntax error in that case, and that you obviously cannot redeclare variables? Java&#8217;s just funny like that, but I suspect it has something to do with the scoping rules in Java. The <code>magic</code> variable inside of the if-statement should be separate, and it is telling you it&#8217;s a duplicate, not that it isn&#8217;t allowed. So I suppose that&#8217;s helpful.</p>
<p>In short, the easy fix is to <em>rename</em> the inner-conflicting variable. So the <code>magic</code> that&#8217;s in the if-statement could be <em>magic2</em> and anything that references it in the if should also be updated. That&#8217;s clear enough. The other possibility is to remove the <code>int</code> declaration. Imagine you were simply setting value instead of declaring. It&#8217;s an easy mistake to make, especially when you&#8217;ve a bunch of declarations repeated.</p>
<p class="signoff">Happy deduplicating!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2012/02/15/java-duplicate-local-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ C: undefined reference to `pow&#8217;</title>
		<link>http://blog.ryanrampersad.com/2011/12/12/c-undefined-reference-to-pow/</link>
		<comments>http://blog.ryanrampersad.com/2011/12/12/c-undefined-reference-to-pow/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 17:25:45 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4586</guid>
		<description><![CDATA[I was helping a friend with a little C-program recently. C is not my language of choice, and when I was tinkering years ago, I was using a Windows compiler and not gcc. Things are a little different in the Ubuntu compilation world. I was receiving an unexpected error message even though I had proper [...]]]></description>
			<content:encoded><![CDATA[<p>I was helping a friend with a little C-program recently. C is not my language of choice, and  when I was tinkering years ago, I was using a Windows compiler and not <em>gcc</em>. Things are a little different in the Ubuntu compilation world. I was receiving an unexpected error message even though I had proper headers.</p>
<blockquote><p>
testing.c:(.text+0&#215;156): undefined reference to `pow&#8217;<br />
testing.c:(.text+0&#215;174): undefined reference to `pow&#8217;<br />
testing.c:(.text+0x18e): undefined reference to `pow&#8217;
</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;math.h&gt; 
#include &lt;time.h&gt;
</pre>
<p>My code was modestly simple. The variables were previously defined and perfectly in order.</p>
<pre class="brush: cpp; title: ; notranslate">
      double left = a * pow(b, 3);
      double right = pow(c, 2) - pow(d, e);
</pre>
<p>Apparently, in order to make <em>gcc</em> load the proper library, you need to explicitly tell it to in the call to compilation. <code>gcc -lm testing.c -o math &#038;&#038; ./testing</code></p>
<p>Notice the <em>-lm</em> flag? That tells <em>gcc</em> to load a specific library, and in this case, the math library.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/12/12/c-undefined-reference-to-pow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ scheme: (cons) &#8211; list error &#8211; (&#8220;list&#8221; #x3) #x14</title>
		<link>http://blog.ryanrampersad.com/2011/10/27/scheme-cons-list-error-list-x3-x14/</link>
		<comments>http://blog.ryanrampersad.com/2011/10/27/scheme-cons-list-error-list-x3-x14/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 17:27:06 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4523</guid>
		<description><![CDATA[If one Scheme error wasn&#8217;t enough, I&#8217;ve got another one. This time it&#8217;s from cons. ;The procedure #[compiled-procedure 13 ("list" #x3) #x14 #x103498714] has been called with 1 argument; it requires exactly 2 arguments. My code looked something like this: In Scheme, it&#8217;s not so easy to realize you&#8217;ve missed an argument when you&#8217;re coming [...]]]></description>
			<content:encoded><![CDATA[<p>If one Scheme error wasn&#8217;t enough, I&#8217;ve got another one. This time it&#8217;s from <em>cons</em>.</p>
<blockquote><p>
;The procedure #[compiled-procedure 13 ("list" #x3) #x14 #x103498714] has been called with 1 argument; it requires exactly 2 arguments.</p></blockquote>
<p>My code looked something like this:</p>
<pre class="brush: plain; title: ; notranslate">
(define (get-last-item lst)
  (define (recurse tsl l)
    (if (null? l)
      (car tsl)
      (recurse (cons (car l)) (cdr l))
    )
  )
  (recurse () lst)
)
</pre>
<p>In Scheme, it&#8217;s not so easy to realize you&#8217;ve missed an argument when you&#8217;re coming from a language where anything inside <em>parenthesis</em> are arguments. But in this case, it&#8217;s <code>cons</code>.</p>
<p>Why? It needs two arguments, something to <code>car</code> and something to <code>cdr</code>. That recurse line should look something more like this:</p>
<pre class="brush: plain; title: ; notranslate">
      (recurse (cons (car l) tsl) (cdr l))
</pre>
<p>Now, you may ask, &#8220;how did you know it was <code>cons</code>?&#8221; Aside from looking for something where I messed up arguments (1 instead of 2), I looked at the internal names. When you see something like <strong>#x14 #x103498714</strong> in an error message, and as long as it&#8217;s a scheme procedure itself and not one of those fancy <em>special forms</em>, it will always have that representation internally. I ran <code>cons</code> point-blank in the Scheme interpreter and it returned the representation that shown in the error:</p>
<blockquote><p>#[compiled-procedure 13 ("list" #x3) #x14 #x103498714]</p></blockquote>
<p>I&#8217;m getting better at debugging Scheme code, but it&#8217;s still an uphill climb.</p>
<p class="signoff"><em>Happy cons&#8217;ing</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/10/27/scheme-cons-list-error-list-x3-x14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ scheme: (list-ref) (&#8220;list&#8221; #x26) error</title>
		<link>http://blog.ryanrampersad.com/2011/10/26/scheme-list-ref-list-x26-error/</link>
		<comments>http://blog.ryanrampersad.com/2011/10/26/scheme-list-ref-list-x26-error/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 17:20:40 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[lists]]></category>
		<category><![CDATA[scheme]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4510</guid>
		<description><![CDATA[Coding in scheme requires a different mindset with not only composing backwards expressions but also with debugging errors. Today, I was coding a simple sorting algorithm for a list. I was reciving an error message that mentioned list while there weren&#8217;t any direct list calls. ;The procedure #[compiled-procedure 13 ("list" #x26) #x1a #x10349b102] has been [...]]]></description>
			<content:encoded><![CDATA[<p>Coding in scheme requires a different mindset with not only composing backwards expressions but also with debugging errors. Today, I was coding a simple sorting algorithm for a list. I was reciving an error message that mentioned <em>list</em> while there weren&#8217;t any direct list calls.</p>
<blockquote><p>;The procedure #[compiled-procedure 13 ("list" #x26) #x1a #x10349b102] has been called with 1 argument; it requires exactly 2 arguments.</p></blockquote>
<p>One thing to notice: <em>called with 1 argument; it requires exactly 2 arguments.</em> That is a give away that you&#8217;ve missed argument somewhere, even if the code isn&#8217;t what is mentioned previously, as in this case, <em>list</em>.</p>
<pre class="brush: plain; title: ; notranslate">
  (cond
    ((&lt; (distance (list-ref (- (length pt-list) 1) ) origin) delta-distance)
      (append pt-list p-list)
    )
    ((&gt; (distance (list-ref 0) origin) delta-distance)
      (append p-list pt-list)
    )
    (else
      (append (car parts) p-list (cdr parts))  
    )
  )
</pre>
<p>Looking through that code, it isn&#8217;t really obvious what&#8217;s wrong. Distance takes two &#8220;points&#8221; and calculates the distance between them. Origin is point (0,0) and delta distance is previously calculated. The <code>pt-list</code> was a list of points to sort through and the <code>p-list</code> was a list-ized singular point for insertion. Confused yet? I was too.</p>
<p>Look at the innocent <code>list-ref</code> though? How many arguments does that have? <a href="http://docs.racket-lang.org/reference/pairs.html#(def._((quote._~23~25kernel)._list-ref))">The documentation</a> says it has <em>two arguments</em>. I realized I missed the <em>list</em> argument in the call to <code>list-ref</code>.</p>
<p class="signoff"><em>Happy list-ref&#8217;ing.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/10/26/scheme-list-ref-list-x26-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ Parse error: syntax error, unexpected T_AS</title>
		<link>http://blog.ryanrampersad.com/2011/10/25/parse-error-syntax-error-unexpected-t_as/</link>
		<comments>http://blog.ryanrampersad.com/2011/10/25/parse-error-syntax-error-unexpected-t_as/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 17:37:22 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4098</guid>
		<description><![CDATA[I was doing some PHP work after a long hiatus. You get used to one language and when you back to another, you just forget things sometimes. I received an unexpected T_AS. Parse error: syntax error, unexpected T_AS, expecting &#8216;;&#8217; in /homepages/224/d19925234/htdocs/kdelli/working/index.php on line 18 The error is so descriptive! Well, more so than others, [...]]]></description>
			<content:encoded><![CDATA[<p>I was doing some PHP work after a long hiatus. You get used to one language and when you back to another, you just forget things sometimes. I received an <em>unexpected T_AS</em>.</p>
<blockquote><p>Parse error: syntax error, unexpected T_AS, expecting &#8216;;&#8217; in /homepages/224/d19925234/htdocs/kdelli/working/index.php on line 18</p></blockquote>
<p>The error is so descriptive! Well, more so than others, actually. When do you use the keyword <code>as</code>? In loop declarations! See my code.</p>
<pre class="brush: php; title: ; notranslate">
if ( $query == &quot;places&quot; ) {
    $output = &quot;&quot;;
    for ($locations as $key =&gt; $l) {
        $output .= $l . &quot;\r\n&quot;;
    }    
}

</pre>
<p>What could be wrong? Take a look at the <em>for loop</em> declaration. Notice anything odd about it? I didn&#8217;t either, at first. The <code>as</code> looks right, I took out <code>$key =&gt;</code> but there was no difference. I realized, since I was coming from Java, that <em>for each loops</em> aren&#8217;t just <em>for loops</em> in PHP. They are literally <code>foreach</code> loops.</p>
<p>I corrected the error simply by changing <code>for</code> to <code>foreach</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/10/25/parse-error-syntax-error-unexpected-t_as/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ scheme: Ill-formed special form</title>
		<link>http://blog.ryanrampersad.com/2011/10/05/scheme-ill-formed-special-form/</link>
		<comments>http://blog.ryanrampersad.com/2011/10/05/scheme-ill-formed-special-form/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 17:12:48 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[special]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4419</guid>
		<description><![CDATA[Scheme is notorious for returning unintelligible error messages. For instance, I was working on an iteration and recursion lab this morning and I ran into this oddity and the code that caused it. ;Ill-formed special form: (define sum-range a b count) The error message mentions special form. If you&#8217;re learning Scheme, you should remember that [...]]]></description>
			<content:encoded><![CDATA[<p>Scheme is notorious for returning unintelligible error messages. For instance, I was working on an iteration and recursion lab this morning and I ran into this oddity and the code that caused it.</p>
<blockquote><p>;Ill-formed special form: (define sum-range a b count)</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
(define sum-range a b count)
 ; no procedure code yet
)
</pre>
<p>The error message mentions <em>special form</em>. If you&#8217;re learning Scheme, you should remember that <code>define</code> is a special form. It&#8217;s special in that it does not use the <em>applicative</em> ordering method for evaluation, among other things I suspect. So, somehow, the special form for <code>define</code> is incorrect. Any ideas? Can you spot the <em>syntax error</em>?</p>
<p>Notice that <code>sum-range</code> does not have a leading parenthesis? The procedure needs to be lead by a parenthesis so that it is its own expression (in terms of the special-formy-ness that is <code>define</code>). In short, the code should have read like so:</p>
<pre class="brush: plain; title: ; notranslate">
(define (sum-range a b count)
 ; no procedure code yet
)
</pre>
<p>It was really as easy as that.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/10/05/scheme-ill-formed-special-form/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>★ scheme: factorial infinite recursion</title>
		<link>http://blog.ryanrampersad.com/2011/09/29/scheme-factorial-infinite-recursion/</link>
		<comments>http://blog.ryanrampersad.com/2011/09/29/scheme-factorial-infinite-recursion/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 12:51:39 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=4422</guid>
		<description><![CDATA[My textbook explains basic recursion with the age old factorial. The problem with that is that the code given might be a tiny bit buggy if the expectations aren&#8217;t kept on the straight and narrow. The given code from the book is: I left this code as is. Factorials are easy to understand, pick any [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_%_sec_1.2.1">textbook explains basic recursion</a> with the age old <em>factorial</em>. The problem with that is that the code given might be a tiny bit buggy if the expectations aren&#8217;t kept on the straight and narrow.</p>
<p>The given code from the book is:</p>
<pre class="brush: plain; title: ; notranslate">
(define (factorial n)
  (if (= n 1)
      1
      (* n (factorial (- n 1)))))
</pre>
<p>I left this code as is. Factorials are easy to understand, pick any <em>n-value</em> and multiply each value below it until you get to 1.</p>
<p>Imagine you made a call to <code>(factorial 2)</code>. The result will be <em>2</em> because of <em>1 * 2</em>. Then imagine <code>(factorial 1)</code>, and the result being <em>1</em> because the truthy-branch of the if-statement is used instead of the calculation branch. So far, so good, right?</p>
<p>Now, imagine you had a call to <code>(factorial 0)</code>. What happens? You&#8217;re going to get a dreaded infinite recursion error, which will look similar to this:</p>
<blockquote><p>;Aborting!: maximum recursion depth exceeded</p></blockquote>
<p>What could cause this behavior? Perhaps the author of this method simply really trusted himself to not miscount in his recursion. Perhaps it was an oversight, but whatever the case, look at the condition that controls the procedure. Notice <code>if (= n 1)</code>, and that there is only <em>a single value</em> that will make this procedure <em>stop</em>, and that is 1.</p>
<p>To fix this to accept 0, while not affecting the result of the factorial numerically, you can simply exchange the <code>(= n 1)</code> with <code>(&lt; n 1)</code>. This will force a 1 whenever n is less than 1, so that covers 0 and all negative values.</p>
<p class="signoff"><em>Happy factorial!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/09/29/scheme-factorial-infinite-recursion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

