Lambda vs. function

Waldemar Horwat waldemar at google.com
Tue Oct 21 18:14:54 PDT 2008


Maciej Stachowiak wrote:
> 
> On Oct 20, 2008, at 2:23 PM, Dave Herman wrote:
> 
>>> Yes, that's what I was referring to earlier.  Do you now understand my
>>> mail from 10/17/2008 12:39?
>>
>> You mean these examples?
>>
>>> lambda h(x) {
>>> switch (x) {
>>>   case 1:
>>>     g();
>>>     break;
>>>   case 2:
>>>     ...
>>> }
>>> }
>>
>> I doubt there's any clean way to fit tail positions into a switch
>> statement, since it works by jumping out of the statement. I'll have to
>> look closer at the semantics of the completion value of a switch
>> statement; there might be some reasonably straightforward notion of a
>> tail position. But I doubt it.
> 
> I don't think you can represent tail position in a switch statement with 
> your "attribute grammar" notion, but it's clear to me that the statement 
> immediately before a break statement, or else the last statement in the 
> last case or default clause, is in tail position. There is no reason 
> this should be any different than the if/else case.
> 
> Regards,
> Maciej

Of course, if you do that then you're back to what Dave was complaining about:  break becomes like return in that it can jump out of various kinds of places.  For example:

switch (x) {
  case 1: {
    if (x) {
      g();
      break;
    }
    h();
    break;
  }
  case 2:
    try {
      h();
      break;
    } finally ...
  case 3:
    ...
}

    Waldemar


More information about the Es-discuss mailing list