I think the current syntax is fine, honestly. Part of the power of it is
that it doesn't feel like you're creating an anonymous function – instead,
it feels like functions can introduce blocks with their own evaluation
semantics. It's just an illusion, but I suspect that's where both the power
and the confusion come from. I do recall this being one of the more
mysterious aspects of Ruby when I first encountered it, but it's so popular
there that basically no one even uses for loops anymore in idiomatic Ruby
code – they use the .each method with a code block instead.


On Mon, Apr 28, 2014 at 5:44 PM, Peter Simon <[email protected]> wrote:

> How about this slight variation of Kevin's first suggestion?
>
> open("file.txt","wa") use (f) -> write(f,"hello")
>
> It's very clear that an anonymous function is being defined, and there is
> a reminder that this function is being used as the first argument of the
> preceding function.
>
>
>
>
> On Monday, April 28, 2014 2:11:08 PM UTC-7, Ivar Nesje wrote:
>>
>> How about dropping do and just use function.
>>
>> open("file.txt","wa") function(f)
>>     write(f,"hello")
>> end
>>
>> Hmm.. It doesn't look as pretty as I imagined it before writing it out.
>>
>>

Reply via email to