<?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: Macros in jQuery</title>
	<atom:link href="http://james.padolsey.com/javascript/macros-in-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com/javascript/macros-in-jquery/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:03:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: victoria</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-29002</link>
		<dc:creator>victoria</dc:creator>
		<pubDate>Wed, 28 Apr 2010 15:22:21 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-29002</guid>
		<description>@sedat:ah i see... now I get it.
Thanks.</description>
		<content:encoded><![CDATA[<p>@sedat:ah i see&#8230; now I get it.<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joseanpg</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-26085</link>
		<dc:creator>joseanpg</dc:creator>
		<pubDate>Fri, 08 Jan 2010 17:31:27 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-26085</guid>
		<description>What is the purpose of the second argument of &lt;code&gt;register&lt;/code&gt; function? Not used.


&lt;pre&gt;
    function register(name, fn) {
        
        fn = fn &#124;&#124; proto[name]; // For what?
        
        proto[name] = function() {
            this.add(name, arguments);
            return this;
        };
        
    }
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>What is the purpose of the second argument of <code>register</code> function? Not used.</p>
<pre>
    function register(name, fn) {

        fn = fn || proto[name]; // For what?

        proto[name] = function() {
            this.add(name, arguments);
            return this;
        };

    }
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-26031</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 06 Jan 2010 10:14:06 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-26031</guid>
		<description>@Nick, I probably was a bit quick to judge. In a flame war, I&#039;d be one those people blindly defending JS until the cows come home... To me, there&#039;s no alternative, it&#039;s great!

CS does look pretty cool, and kudos to the creator, but, for me, its yet another abstraction that fuzzes the details. I know I can&#039;t really talk, being involved with one the highest abstracted programming stacks on the planet (the &quot;web&quot; stack).

Anyway, thanks for the info. I can see why CS (and other similar things) would be appealing to some, but for me, having being brought up with C-like languages, I feel quite at home with JS. I have been looking at Perl recently though, which is pretty cool.</description>
		<content:encoded><![CDATA[<p>@Nick, I probably was a bit quick to judge. In a flame war, I&#8217;d be one those people blindly defending JS until the cows come home&#8230; To me, there&#8217;s no alternative, it&#8217;s great!</p>
<p>CS does look pretty cool, and kudos to the creator, but, for me, its yet another abstraction that fuzzes the details. I know I can&#8217;t really talk, being involved with one the highest abstracted programming stacks on the planet (the &#8220;web&#8221; stack).</p>
<p>Anyway, thanks for the info. I can see why CS (and other similar things) would be appealing to some, but for me, having being brought up with C-like languages, I feel quite at home with JS. I have been looking at Perl recently though, which is pretty cool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Fitzgerald</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-26027</link>
		<dc:creator>Nick Fitzgerald</dc:creator>
		<pubDate>Wed, 06 Jan 2010 07:34:16 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-26027</guid>
		<description>&lt;blockquote&gt;
Using CS would be the same as using GWT and compiling to typically less-than-good JavaScript.
&lt;/blockquote&gt;

James, I don&#039;t think it&#039;s quite fair to lump CoffeeScript (and ParenScript) in to the same group as GWT (or Pyjamas, etc...).

Both CS and PS expressions compile one-to-one with JS, keep the same variable names, and even indent properly so that the compiled JS looks &quot;handwritten&quot; or pretty printed. This makes a world of difference when debugging; perhaps the most common complaint of X-to-javascript compilers.

GWT, on the other hand, is a full blown Java framework and GUI toolkit. Who knows what kind of code ends up being generated?

&lt;blockquote&gt;
It’s JS for people that don’t like JS…
&lt;/blockquote&gt;

I think in most cases its language geeks having fun. Personally, I love a lot about JS and dislike some too (Crockford has pointed out the beauties and flaws of JS so completely that it is almost cliche to reference or quote him any more). I think there is nothing wrong with exploring an alternate syntax; Because that is really all CS and PS are (with the exception of ParenScript&#039;s macros, but I digress).

I will risk being labeled cliche: I believe it was Crockford that has the somewhat famous quote about JS being Lisp in C&#039;s clothing or whatnot; why not see what it looks like when we strip the C syntax from it?

PS: I like the new design on your site, its snazzy :)</description>
		<content:encoded><![CDATA[<blockquote><p>
Using CS would be the same as using GWT and compiling to typically less-than-good JavaScript.
</p></blockquote>
<p>James, I don&#8217;t think it&#8217;s quite fair to lump CoffeeScript (and ParenScript) in to the same group as GWT (or Pyjamas, etc&#8230;).</p>
<p>Both CS and PS expressions compile one-to-one with JS, keep the same variable names, and even indent properly so that the compiled JS looks &#8220;handwritten&#8221; or pretty printed. This makes a world of difference when debugging; perhaps the most common complaint of X-to-javascript compilers.</p>
<p>GWT, on the other hand, is a full blown Java framework and GUI toolkit. Who knows what kind of code ends up being generated?</p>
<blockquote><p>
It’s JS for people that don’t like JS…
</p></blockquote>
<p>I think in most cases its language geeks having fun. Personally, I love a lot about JS and dislike some too (Crockford has pointed out the beauties and flaws of JS so completely that it is almost cliche to reference or quote him any more). I think there is nothing wrong with exploring an alternate syntax; Because that is really all CS and PS are (with the exception of ParenScript&#8217;s macros, but I digress).</p>
<p>I will risk being labeled cliche: I believe it was Crockford that has the somewhat famous quote about JS being Lisp in C&#8217;s clothing or whatnot; why not see what it looks like when we strip the C syntax from it?</p>
<p>PS: I like the new design on your site, its snazzy <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dss</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-26022</link>
		<dc:creator>Dss</dc:creator>
		<pubDate>Tue, 05 Jan 2010 21:53:04 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-26022</guid>
		<description>ah ok.. now I get it</description>
		<content:encoded><![CDATA[<p>ah ok.. now I get it</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-26005</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 05 Jan 2010 15:13:53 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-26005</guid>
		<description>@jerone, I did consider something similar to &lt;code&gt;endMacro()&lt;/code&gt; but ended up scrapping it -- it was getting a bit too complicated IMO.

@K.Adam, good point! I did consider this too... But I thought the plugin-like syntax would be a little cleaner. 

@Dss, there is no difference -- that&#039;s the point!

Macros are useful in the way that plugins are useful... You don&#039;t need to write out all that code every time you want to use it. 

@Nick, some interesting stuff there! I&#039;ve looked at CoffeeScript, but I can&#039;t say I&#039;m very enthused. Using CS would be the same as using GWT and compiling to typically less-than-good JavaScript. It&#039;s JS for people that don&#039;t like JS...</description>
		<content:encoded><![CDATA[<p>@jerone, I did consider something similar to <code>endMacro()</code> but ended up scrapping it &#8212; it was getting a bit too complicated IMO.</p>
<p>@K.Adam, good point! I did consider this too&#8230; But I thought the plugin-like syntax would be a little cleaner. </p>
<p>@Dss, there is no difference &#8212; that&#8217;s the point!</p>
<p>Macros are useful in the way that plugins are useful&#8230; You don&#8217;t need to write out all that code every time you want to use it. </p>
<p>@Nick, some interesting stuff there! I&#8217;ve looked at CoffeeScript, but I can&#8217;t say I&#8217;m very enthused. Using CS would be the same as using GWT and compiling to typically less-than-good JavaScript. It&#8217;s JS for people that don&#8217;t like JS&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dss</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-26002</link>
		<dc:creator>Dss</dc:creator>
		<pubDate>Tue, 05 Jan 2010 14:36:58 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-26002</guid>
		<description>I don&#039;t understand. jQuery natively can link multiple effects on one line.

What is different between:

&lt;pre lang=&quot;javascript&quot;&gt;
var myMacro = jQuery.macro(&#039;myMacro&#039;);
myMacro.css(&#039;color&#039;, &#039;red&#039;).scrollTop(0).addClass(&#039;foo&#039;);
jQuery(&#039;div&#039;).myMacro(); // All that stuff happens! css()-&gt;scrollTop()-&gt;addClass()
&lt;/pre&gt;

and simply:
&lt;pre lang=&quot;javascript&quot;&gt;
$(&#039;div&#039;).css(&#039;color&#039;, &#039;red&#039;).scrollTop(0).addClass(&#039;foo&#039;);&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I don&#8217;t understand. jQuery natively can link multiple effects on one line.</p>
<p>What is different between:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> myMacro <span class="sy0">=</span> jQuery.<span class="me1">macro</span><span class="br0">&#40;</span><span class="st0">'myMacro'</span><span class="br0">&#41;</span><span class="sy0">;</span>
myMacro.<span class="me1">css</span><span class="br0">&#40;</span><span class="st0">'color'</span><span class="sy0">,</span> <span class="st0">'red'</span><span class="br0">&#41;</span>.<span class="me1">scrollTop</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">'foo'</span><span class="br0">&#41;</span><span class="sy0">;</span>
jQuery<span class="br0">&#40;</span><span class="st0">'div'</span><span class="br0">&#41;</span>.<span class="me1">myMacro</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// All that stuff happens! css()-&gt;scrollTop()-&gt;addClass()</span></pre></div></div>

<p>and simply:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span class="br0">&#40;</span><span class="st0">'div'</span><span class="br0">&#41;</span>.<span class="me1">css</span><span class="br0">&#40;</span><span class="st0">'color'</span><span class="sy0">,</span> <span class="st0">'red'</span><span class="br0">&#41;</span>.<span class="me1">scrollTop</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">'foo'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Sedat Kumcu</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-25987</link>
		<dc:creator>Sedat Kumcu</dc:creator>
		<pubDate>Sun, 03 Jan 2010 12:23:13 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-25987</guid>
		<description>Hi James, thanks for this useful article. 
But I saw the first time macro plug-in. This plugin look like very useful. good works.</description>
		<content:encoded><![CDATA[<p>Hi James, thanks for this useful article.<br />
But I saw the first time macro plug-in. This plugin look like very useful. good works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: K. Adam Christensen</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-25964</link>
		<dc:creator>K. Adam Christensen</dc:creator>
		<pubDate>Wed, 30 Dec 2009 11:47:14 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-25964</guid>
		<description>Very interesting.  One thing that I want to add to Ben Nadel&#039;s comment is that this will work with existing plugins if, and only if, this plugin is loaded *after* those plugins have registered themselves.

Something else to consider:  If the goal is not to extend the jQuery API, then as you know, this macro plugin does break that goal.  What if, instead, the macros were kept to the macro object.  For example

&lt;pre lang=&quot;javascript&quot;&gt;
jQuery.macro(&#039;cousins&#039;).parent().siblings().children();
jQuery(&#039;#elem&#039;).macro(&#039;cousins&#039;); // YEH!
jQuery(&#039;#elem&#039;).replay(&#039;cousins&#039;); // Alternative naming
&lt;/pre&gt;

This way, you can leave the jQuery object a little less cluttered.  Naturally, the downside to this is if that macro ever needs to become a full fledge plugin, you would have to do more refactoring to make the conversion.</description>
		<content:encoded><![CDATA[<p>Very interesting.  One thing that I want to add to Ben Nadel&#8217;s comment is that this will work with existing plugins if, and only if, this plugin is loaded *after* those plugins have registered themselves.</p>
<p>Something else to consider:  If the goal is not to extend the jQuery API, then as you know, this macro plugin does break that goal.  What if, instead, the macros were kept to the macro object.  For example</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span class="me1">macro</span><span class="br0">&#40;</span><span class="st0">'cousins'</span><span class="br0">&#41;</span>.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">siblings</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">children</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
jQuery<span class="br0">&#40;</span><span class="st0">'#elem'</span><span class="br0">&#41;</span>.<span class="me1">macro</span><span class="br0">&#40;</span><span class="st0">'cousins'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// YEH!</span>
jQuery<span class="br0">&#40;</span><span class="st0">'#elem'</span><span class="br0">&#41;</span>.<span class="me1">replay</span><span class="br0">&#40;</span><span class="st0">'cousins'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// Alternative naming</span></pre></div></div>

<p>This way, you can leave the jQuery object a little less cluttered.  Naturally, the downside to this is if that macro ever needs to become a full fledge plugin, you would have to do more refactoring to make the conversion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SMiGL</title>
		<link>http://james.padolsey.com/javascript/macros-in-jquery/comment-page-1/#comment-25958</link>
		<dc:creator>SMiGL</dc:creator>
		<pubDate>Wed, 30 Dec 2009 08:20:43 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1327#comment-25958</guid>
		<description>jQuery.macro is great and useful plugin. Thanks for simple and cool post!</description>
		<content:encoded><![CDATA[<p>jQuery.macro is great and useful plugin. Thanks for simple and cool post!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.192 seconds -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-07 10:39:24 -->

