On 10.07.2010 17:54, Caleb Clausen wrote:
> On 7/9/10, Jan Lelis<prog / janlelis.de>  wrote:
>> So what about allowing to specify, which end belongs to which start?
>> I've thought about something like this:
>>
>>         end|do
>>       end|if
>>     end|def
>>
>> or
>>
>>         end~do
>>       end~if
>>     end~def
>>
>> or
>>
>>         end:do
>>       end:if
>>     end:def
>
> I've been told that very old versions of ruby used to have this
> feature, using a space to separate the end from the keyword being
> terminated instead of | ~ or : as suggested by Jan. So, in other
> words, you could write:
>
> if foo
>    bar
> end if
>
>
> I like this syntax far above anything involving punctuation.
> Supposedly, this feature was removed when the 'modifier' versions of
> if and unless and etc were added to the language; keeping both was
> difficult to support in the parser.

I don't want to advocate this but concatenating "end" directly with the 
opening keyword is probably easy to do because it will create a whole 
bunch of new tokens , so there would be

endclass
endmodule
enddef
endbegin
endif
endunless
endwhile
enduntil
endfor
enddo
endcase

Did I miss one?

Each of those would be then alternatively allowed to "end", so you could 
write

begin
   if foo
   else
     case x
     when y
     when z
     endcase
   end
endbegin

I still don't like it.

> However, after giving it a little
> thought, it seems to me that a form of this feature could be
> reintroduced with not an excessive amount of trouble. If the keyword
> being terminated is immediately followed by a newline or semicolon, it
> is treated as a Jan wants. Otherwise, it's treated as a 'modifier'
> flow control (if it's an if or unless or etc).

IMHO this is not feasible: "if <condition>" is almost always followed by 
a line break.  And think about

begin
   puts "aaa"
end if
   x > 100

This is perfectly legal with the current syntax but it looks like "end 
if" would be a terminator while in reality it is a statement modifier.

> I could write a RubyLexer-based preprocessor which does this pretty
> easily. However, I'm not terribly motivated. This doesn't seem like
> that useful a feature to me and I've got so much else to work on....

:-)

Cheers

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/