KBD

Keith Devens .com

Saturday, March 20, 2010 Flag waving
Never ascribe to malice, that which can be explained by incompetence. – Napoleon Bonaparte

Archive: November 24, 2005

← November 23, 2005November 25, 2005 →

Daily link icon Thursday, November 24, 2005

Thanksgiving

ongoing · Giving Thanks:

There’s a lot to be said for a major civic celebration that has nothing to do with theologically-significant births or deaths that happened millennia ago in the Middle East.

Update (11/25 12:55 eastern):
Ben Franklin on Thanskgiving:

The Real Story of the First Thanksgiving
By Benjamin Franklin (1785)

“There is a tradition that in the planting of New England, the first settlers met with many difficulties and hardships, as is generally the case when a civiliz’d people attempt to establish themselves in a wilderness country. Being so piously dispos’d, they sought relief from heaven by laying their wants and distresses before the Lord in frequent set days of fasting and prayer. Constant meditation and discourse on these subjects kept their minds gloomy and discontented, and like the children of Israel there were many dispos’d to return to the Egypt which persecution had induc’d them to abandon.

“At length, when it was proposed in the Assembly to proclaim another fast, a farmer of plain sense rose and remark’d that the inconveniences they suffer’d, and concerning which they had so often weary’d heaven with their complaints, were not so great as they might have expected, and were diminishing every day as the colony strengthen’d; that the earth began to reward their labour and furnish liberally for their subsistence; that their seas and rivers were full of fish, the air sweet, the climate healthy, and above all, they were in the full enjoyment of liberty, civil and religious.

“He therefore thought that reflecting and conversing on these subjects would be more comfortable and lead more to make them contented with their situation; and that it would be more becoming the gratitude they ow’d to the divine being, if instead of a fast they should proclaim a thanksgiving. His advice was taken, and from that day to this, they have in every year observ’d circumstances of public felicity sufficient to furnish employment for a Thanksgiving Day, which is therefore constantly ordered and religiously observed.”

PHP sucks yet again

Via Jeff, just found these PHP Developers' Meeting minutes on PHP 6. Call-time pass-by-reference was deprecated for no reason somewhere along the line. Now they're un-deprecating it, changing it back from an E_WARNING (they claim it's E_NOTICE, but it's not) to just E_STRICT (though they're also turning E_STRICT on by default):

The first issue that we raised was changing the E_NOTICE error for call-time-pass-by-reference to an E_ERROR, or simply throwing a parse error. We argued over this case and we decided to change this E_NOTICE to an E_STRICT instead as it was argued that there is nothing wrong with doing a call-time pass by reference.

Argh! I vented my frutration about this feature being deprecated since it broke some of PHP's built-in functionality. Now it's just "Sorry, there really was no reason for us to deprecate that feature. Our bad".

On the bright side, it looks like they're removing magic quotes and register globals.

Also, the PHP people couldn't agree on how to fix a sore spot in the language if you develop with notices on. You commonly have to do things like the following:

<?php
$foo 
= isset($_REQUEST['foo']) ? $_REQUEST['foo'] : NULL;
?>

so that you don't get an error if $_REQUEST['foo'] doesn't exist. Obviously that's really cumbersome to do over and over again. They proposed adding an ifsetor function that does essentially the following:

<?php
function ifsetor($var$default){
    return isset(
$var) ? $var $default;
}
?>

But note the special casing in their example:

<?php
$foo 
ifsetor($_GET['foo'], 42);
?>

That's not allowed if $_GET['foo'] doesn't already exist; if I call my version of ifsetor I get a NOTICE error. So, they'd add a special case in the language (just like they already have with isset) to make it appear as if $_GET['foo'] returns NULL if it's not defined. But if that was the case it would defeat the whole purpose of the feature anyway!

However, they decided against ifsetor and instead are adding a syntax extension that lets you elide the middle value for the ternary operator for the common case as shown above, which would allow:

<?php
$foo 
$_REQUEST['foo'] ?: NULL;
?>

Which really isn't bad at all. Only:

Instead of implementing ifsetor() we remove the requirement for the "middle" parameter to the ?: operator. The middle parameter then defaults to the first one. If the first parameter is not set, then we will still throw an E_NOTICE.

So, again the feature becomes useless for the common case I've been talking about. However, they've provided the following for me:

<?php
$foo 
input_filter_get(GET'foo'FL_INT) ?: 42;
?>

Great.

FYI, I have a few convenience functions just for these common cases:

<?php
function g(&$var$key$default NULL){ #make it easy to develop with notices on
    
return isset($var[$key]) ? $var[$key] : $default;
}
function 
r($key){ return g($_REQUEST$key); }
?>

g optionally does some more than that, but that's the base case.

Now, this I'm very happy about. They're getting rid of the `{}` indexing for strings (which they admit was a hack to simplify their parser) and allowing slicing notation like Python does. That's excellent. They k'd on named parameters, however.

Note: any emphasis in any quote above is my own.

  1. Evaluation: moving from Java to Ruby on Rails for the CenterNet rewrite (via John Wiseman). To read.

       (0) Tags: [Java, Programming, Ruby on Rails]
  2. Behaviour : Using CSS selectors to apply Javascript behaviours (via Keith Gaughan).

       (0) Tags: [Programming]
  3. Scott Adams: God's Debris (via, via). To read.

       (1) Tags: [Religion]
  4. SyFy: 'Spike' Movie Comes One Step Closer (via WHEDONesque, but they removed the post):

    ... Tim Minear has agreed to both write and direct the television movie for the beloved character. Minear, who has written and directed for “Buffy,” “Angel” and Joss Whedon’s short-lived “Firefly” series, said he is looking forward to continuing his work in the Buffyverse and agreed to work on the project the second Whedon approached him.

    “I had lunch with Joss and he asked me [if] I wanted to write and direct some blond vampire movie thing,” said Minear. “Should I do it? I of course said yes right off. Still, anything under 13 hours scares me and anything over 13 hours … um, I got nothing.”

    Bwa ha ha ha. Too funny. But sad Smiley frowning

       (0) Tags: [TV/Movies]

PLNews: IronPython Demo Video Available

PLNews: IronPython Demo Video Available. To watch. Argh, you need Internet Explorer to play it. Bah.

Oh my goodness. First time through the video IE blocked the popup the video requires half-way through. Then I temporarily enabled popups in IE, and this time around the Google toolbar bundled with my computer (never turned it off since I've only used IE once to download Firefox) blocked it. Argh! And I can't even get to the Google toolbar for this window since the window has no toolbars. They could have just done the normal thing and opened up a Windows Media Player instance and been done with it.

Hey, neat presentation so far. But why does everyone who works for Microsoft sound like they've drunk the Kool-aid?

Whoa, I didn't know you could do the following in the Python interactive shell:

>>> foo = ["foo", "bar", "baz"]
>>> foo
['foo', 'bar', 'baz']
>>> bar = _
>>> bar
['foo', 'bar', 'baz']

Very cool when he debugged Python, going through stack frames back into the C# code that called it.

← November 23, 2005November 25, 2005 →
March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

I hate ASP.NET

I hate ASP... I was doing wonders​with PHP, then suddenly one of my​clients...

Johnies: Mar 17, 6:14am

Quantum physics and free will

I knew you were going to say that....

Tom Massey: Mar 15, 9:26pm

Generated in about 0.159s.

(Used 7 db queries)