On Feb 1, 2008 12:01 PM, Brendan Eich <[EMAIL PROTECTED]> wrote:
> On Jan 31, 2008, at 5:13 PM, Mark Filipak wrote:
>
> > What I have to write now:
> >
> >  getFirstChildOfElementWithTagName(Papa, 'baby');
> >
> > What I'd like to be able to write:
> >
> >  getFirstChildOfElement(Papa)withTagName('baby');
>
> If you put a . after the first ) then you can write such a chained
> expression today. It costs one more function object and one more .
> character, but if it's important to you for clarity, those costs may
> be worth paying.

Also, I may not have the syntax exactly right, but I believe you can
also do something like this:

function getFirstChild(argObj:{element:XML, tagName:AnyString}):XML {
    return element.(name() == tagName)[0];
}

var papa:XML;
// ...
var firstborn:XML = getFirstChild({element: papa, tagName: "baby"});

(Actually, in this case, the e4x syntax is so succinct that the
function is kind of pointless, but you get the idea -- use a single
argument, of an ad hoc record type, to clarify argument roles.)

-- 
T. Michael Keesey
Director of Technology
Exopolis, Inc.
2894 Rowena Avenue Ste. B
Los Angeles, California 90039
http://exopolis.com/
--
http://3lbmonkeybrain.blogspot.com/
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to