Mr. Eich: Thank you for your suggestion. Unless I've been spending time with Mescalito, to implement
getFirstChildOfElement(Papa).withTagName('baby'), since it has no idea which child is targeted, the first function would have to return an array of all children. Thus .withTagName() would have to be added as a method of Array. Correct? I'm not sure it would be wise to add the overhead as my example is but one of a great many such functions I would wish to create. BTW, I already use your suggested technique to emulate such things as getComputedStyle(Element,'').getPropertyValue(propName) in my IE6 DOM compatibility library. Mr. Keesey: Thank you for your response. I can't begin to fathom what you have written <grin>. And Mr. Hall: Thank you for your thoughts. I wish there was a clean way to add my pet functionality as I've always felt restricted by traditional function syntax but as you have pointed out, doing so would create problems. Excuse the noise from the hinterland. I'm out of my depth. You folks carry on with your good work. I'm sure I'll be happy with Es4 and I will use it. Before I sign out, may I ask if any of you have experience with Snobol? It is, in my opinion, a superior string processing language the core concepts of which would make an excellent addition to regular expressions. Regards, Mark Filipak T. Michael Keesey wrote: > 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.) > _______________________________________________ Es4-discuss mailing list Es4-discuss@mozilla.org https://mail.mozilla.org/listinfo/es4-discuss