<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: I want enums in PHP</title>
	<atom:link href="http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/</link>
	<description>Dagfinn Reiersøl on PHP, agile development, Ruby and other addictive substances</description>
	<lastBuildDate>Fri, 23 Jul 2010 20:17:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: dagfinn</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-62</link>
		<dc:creator>dagfinn</dc:creator>
		<pubDate>Fri, 23 May 2008 13:26:02 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-62</guid>
		<description>&lt;p&gt;Thanks. I see your point; it does feel wrong. My point is avoiding bugs that are hard to find. That&#039;s why I want to get a hard, loud error message when I misspell the role name. Using error_reporting() as someone suggested is not quite strong enough.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Thanks. I see your point; it does feel wrong. My point is avoiding bugs that are hard to find. That&#8217;s why I want to get a hard, loud error message when I misspell the role name. Using error_reporting() as someone suggested is not quite strong enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stereofrog</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-64</link>
		<dc:creator>stereofrog</dc:creator>
		<pubDate>Fri, 23 May 2008 12:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-64</guid>
		<description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;finally got time to click your sig on sitepoint. Nice blog you have here!&lt;/p&gt;
&lt;p&gt;I understand your concerns about strings vs constants. I don&#039;t think the problem with  &quot;if($role == &#039;administrator&#039;)&quot; is that is can be misspelled (so can the constant too), but it just &quot;feels&quot; wrong. &quot;Look, it&#039;s quoted,  it a literal value and we dont like literals in our code&quot;. What actually would be helpful here is a rubys interning operator (colon). :foobar in ruby basically says &quot;I dont care how exactly this is stored, the point is when I&#039;m using this here and there I&#039;m referring to the same thing&quot;&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>finally got time to click your sig on sitepoint. Nice blog you have here!</p>
<p>I understand your concerns about strings vs constants. I don&#8217;t think the problem with  &#8220;if($role == &#8216;administrator&#8217;)&#8221; is that is can be misspelled (so can the constant too), but it just &#8220;feels&#8221; wrong. &#8220;Look, it&#8217;s quoted,  it a literal value and we dont like literals in our code&#8221;. What actually would be helpful here is a rubys interning operator (colon). :foobar in ruby basically says &#8220;I dont care how exactly this is stored, the point is when I&#8217;m using this here and there I&#8217;m referring to the same thing&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tawfiq</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-63</link>
		<dc:creator>tawfiq</dc:creator>
		<pubDate>Wed, 21 May 2008 08:48:52 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-63</guid>
		<description>&lt;p&gt;if(ereg(&quot;ADMINISTRATOR&quot;,$roles))&lt;/p&gt;
&lt;p&gt;please go to be enums in php&lt;br /&gt;
and than go to the hell&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>if(ereg(&#8220;ADMINISTRATOR&#8221;,$roles))</p>
<p>please go to be enums in php<br />
and than go to the hell</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dagfinn</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-49</link>
		<dc:creator>dagfinn</dc:creator>
		<pubDate>Tue, 13 May 2008 06:35:10 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-49</guid>
		<description>&lt;p&gt;One (probably last) comment to the off-topic discussion started by Derick. Expressions like &quot;meaningless&quot; and &quot;do your homework&quot; give (me, and probably others) an impression of implied critcism. If that was the intention, it&#039;s not clear and specific enough to be useful to me as such. So I will choose to assume that the impression is a misunderstanding, and that Derick&#039;s intention was simply to give information.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>One (probably last) comment to the off-topic discussion started by Derick. Expressions like &#8220;meaningless&#8221; and &#8220;do your homework&#8221; give (me, and probably others) an impression of implied critcism. If that was the intention, it&#8217;s not clear and specific enough to be useful to me as such. So I will choose to assume that the impression is a misunderstanding, and that Derick&#8217;s intention was simply to give information.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Ray</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-61</link>
		<dc:creator>Jeff Ray</dc:creator>
		<pubDate>Tue, 13 May 2008 06:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-61</guid>
		<description>&lt;p&gt;I agree with Nick Lo that promoting discussion is a good way to &quot;do your homework&quot;.  Just because someone hasn&#039;t submitted a bug or change request yet, that doesn&#039;t mean they won&#039;t eventually submit one after having some good pier review of the concern.  Lay off guys...&lt;/p&gt;
&lt;p&gt;On topic, I thing Enums would be a handy thing as well.  Is it critical? No. Would it be useful in some situations? Yes.  &lt;/p&gt;
&lt;p&gt;I would say that there are multiple ways to get around enums not being present, and there are probably more times than not that a constant or a static constant class would be an equally functional fit.  But there are times when you can just tell as a programmer, that a situation is ideal for enums, and finding a workaround just seems awquard.  &lt;/p&gt;
&lt;p&gt;It would be good to have them.  Does the absence of enums detract from the functionality of the language?  Probably not.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>I agree with Nick Lo that promoting discussion is a good way to &#8220;do your homework&#8221;.  Just because someone hasn&#8217;t submitted a bug or change request yet, that doesn&#8217;t mean they won&#8217;t eventually submit one after having some good pier review of the concern.  Lay off guys&#8230;</p>
<p>On topic, I thing Enums would be a handy thing as well.  Is it critical? No. Would it be useful in some situations? Yes.  </p>
<p>I would say that there are multiple ways to get around enums not being present, and there are probably more times than not that a constant or a static constant class would be an equally functional fit.  But there are times when you can just tell as a programmer, that a situation is ideal for enums, and finding a workaround just seems awquard.  </p>
<p>It would be good to have them.  Does the absence of enums detract from the functionality of the language?  Probably not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Lo</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-60</link>
		<dc:creator>Nick Lo</dc:creator>
		<pubDate>Mon, 12 May 2008 23:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-60</guid>
		<description>&lt;p&gt;@Derick: &quot;Your blog has no meaning for the PHP developers, as they&#039;re way to busy with other things - remember that.&quot; Similarly many developers (and I don&#039;t just mean PHP developers) have little time for the PHP internals as they&#039;re way too busy with other things!&lt;/p&gt;
&lt;p&gt;I think it was quite clear that Dagfinn was merely raising a topic of conversation which in many ways IS a way to &quot;do your homework&quot; by inviting different ideas.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>@Derick: &#8220;Your blog has no meaning for the PHP developers, as they&#8217;re way to busy with other things &#8211; remember that.&#8221; Similarly many developers (and I don&#8217;t just mean PHP developers) have little time for the PHP internals as they&#8217;re way too busy with other things!</p>
<p>I think it was quite clear that Dagfinn was merely raising a topic of conversation which in many ways IS a way to &#8220;do your homework&#8221; by inviting different ideas.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-59</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Mon, 12 May 2008 15:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-59</guid>
		<description>&lt;p&gt;Instead of using an object just for that - which is an extra overhead to the server - you can use constants. Here is an example :&lt;/p&gt;
&lt;p&gt;define ( &#039;ADMINISTRATOR&#039;, 1 );&lt;br /&gt;
define ( &#039;REGULAR&#039;, 2 );&lt;/p&gt;
&lt;p&gt;if ( $user == ADMINISTRATOR ){&lt;br /&gt;
....&lt;br /&gt;
}&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Instead of using an object just for that &#8211; which is an extra overhead to the server &#8211; you can use constants. Here is an example :</p>
<p>define ( &#8216;ADMINISTRATOR&#8217;, 1 );<br />
define ( &#8216;REGULAR&#8217;, 2 );</p>
<p>if ( $user == ADMINISTRATOR ){<br />
&#8230;.<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dagfinn</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-58</link>
		<dc:creator>dagfinn</dc:creator>
		<pubDate>Mon, 12 May 2008 06:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-58</guid>
		<description>&lt;p&gt;@Ben Ramsey: I can see I need to think more about how I would want enums to actually work in PHP. I may be giving the impression that I have strong opinions while actually I&#039;m just thinking out loud.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>@Ben Ramsey: I can see I need to think more about how I would want enums to actually work in PHP. I may be giving the impression that I have strong opinions while actually I&#8217;m just thinking out loud.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip Olson</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-57</link>
		<dc:creator>Philip Olson</dc:creator>
		<pubDate>Mon, 12 May 2008 04:10:01 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-57</guid>
		<description>&lt;p&gt;These days some people write blog posts instead of using official means like writing an RFC, a mailing list, and/or filling out a bug report. I think all Derick is saying is don&#039;t expect this feature request to be remembered without using official means.&lt;/p&gt;
&lt;p&gt;And on a related topic, what bugs me [and likely others] most is when people blog about a bug and essentially scream &quot;I found a bug! I found a bug! I found a bug!!!&quot; which ends up on PHP Planet and, well, it&#039;s annoying. Not that you did that... but just saying.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>These days some people write blog posts instead of using official means like writing an RFC, a mailing list, and/or filling out a bug report. I think all Derick is saying is don&#8217;t expect this feature request to be remembered without using official means.</p>
<p>And on a related topic, what bugs me [and likely others] most is when people blog about a bug and essentially scream &#8220;I found a bug! I found a bug! I found a bug!!!&#8221; which ends up on PHP Planet and, well, it&#8217;s annoying. Not that you did that&#8230; but just saying.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Ramsey</title>
		<link>http://blog.agilephp.com/2008/05/11/i-want-enums-in-php/comment-page-1/#comment-56</link>
		<dc:creator>Ben Ramsey</dc:creator>
		<pubDate>Mon, 12 May 2008 01:00:48 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1362#comment-56</guid>
		<description>&lt;p&gt;I also meant to point out that, while it may be obvious to many, not everyone will notice that this is what an enum is essentially doing. When you do this:&lt;/p&gt;
&lt;p&gt;public enum Role { REGULAR, WEBMASTER, ADMINISTRATOR };&lt;/p&gt;
&lt;p&gt;Think of it like this:&lt;/p&gt;
&lt;p&gt;constant REGULAR = new Role(0);&lt;br /&gt;
constant WEBMASTER = new Role(1);&lt;br /&gt;
constant ADMINISTRATOR = new Role(2);&lt;/p&gt;
&lt;p&gt;Obviously, this isn&#039;t possible in PHP right now, but it illustrates how to think of enums. :-)&lt;/p&gt;
&lt;p&gt;You would now have constants that have been initialized as the Role &quot;class,&quot; and you can statically call them on the class and access their methods:&lt;/p&gt;
&lt;p&gt;MyProject_Authorization_RBAC_Role::REGULAR-&gt;getPerms()&lt;/p&gt;
&lt;p&gt;Perhaps I should&#039;ve written my own blog post since my response has turned out to be pretty long. :-)&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>I also meant to point out that, while it may be obvious to many, not everyone will notice that this is what an enum is essentially doing. When you do this:</p>
<p>public enum Role { REGULAR, WEBMASTER, ADMINISTRATOR };</p>
<p>Think of it like this:</p>
<p>constant REGULAR = new Role(0);<br />
constant WEBMASTER = new Role(1);<br />
constant ADMINISTRATOR = new Role(2);</p>
<p>Obviously, this isn&#8217;t possible in PHP right now, but it illustrates how to think of enums. <img src='http://blog.agilephp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>You would now have constants that have been initialized as the Role &#8220;class,&#8221; and you can statically call them on the class and access their methods:</p>
<p>MyProject_Authorization_RBAC_Role::REGULAR-&gt;getPerms()</p>
<p>Perhaps I should&#8217;ve written my own blog post since my response has turned out to be pretty long. <img src='http://blog.agilephp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
