Re: Expanded function syntax

2008-02-05 Thread Jason Orendorff
On Jan 31, 2008 5:08 PM, Mark Filipak [EMAIL PROTECTED] wrote:
 What I have to write now:
   getFirstChildOfElementWithTagName(Papa, 'baby');

If you're not writing something like $(baby:first, Papa), you're
missing out on what the language already has to offer.

-j
___
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss


Re: Expanded function syntax

2008-02-01 Thread T. Michael Keesey
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


Re: Expanded function syntax

2008-02-01 Thread Brendan Eich
On Feb 1, 2008, at 5:28 PM, Mark Filipak wrote:

 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?

No, you could do something that avoids copying. The return value of  
getFirstChildOfElement does not need to be of type Array.

 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.

Snobol and its successor, Icon (are there other offspring?) are neat  
languages. Food for thought in a future edition, since full Unicode  
and Perl 5 regexp syntax are at odds, and we have not pulled the Perl  
6 lever (incompatible, more concise regexp syntax).

/be
___
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss


Expanded function syntax

2008-01-31 Thread Mark Filipak
Hello,

May I make a pitch for an expanded function syntax? This example will 
say it all (I hope).

What I have to write now:

  getFirstChildOfElementWithTagName(Papa, 'baby');

What I'd like to be able to write:

  getFirstChildOfElement(myPapa)withTagName('baby');

  function getFirstChildOfElement(Papa)withTagName(babyTagName) {
alert(Papa.tagName);   // Show Papa's tag name
alert(babyTagName);   // Show baby's desired tag name
  }

I don't think such an expanded capability would have any backward 
compatibility issues. It would make function calls more readable and 
easier to remember.

Thanks, and ciao -- Mark Filipak

___
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss


Expanded function syntax

2008-01-31 Thread Mark Filipak
Hello,

(Sorry. What I meant to write is below.)

May I make a pitch for an expanded function syntax? This example will 
say it all (I hope).

What I have to write now:

 getFirstChildOfElementWithTagName(Papa, 'baby');

What I'd like to be able to write:

 getFirstChildOfElement(Papa)withTagName('baby');

 function getFirstChildOfElement(Papa)withTagName(babyTagName) {
   alert(arguments[0].tagName);   // Show Papa's tag name
   alert(arguments[1]);   // Show desired baby's tag name
 }

I don't think such an expanded capability would have any backward 
compatibility issues. It would make function calls more readable and 
easier to remember.

Ciao -- Mark Filipak


___
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss