On Mon, Apr 28, 2014 at 2:57 PM, Stefan Karpinski <[email protected]>wrote:

> 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.
>

The thing is, it *is* actually an anonymous function, with all that that
entails (lack of specialization, etc.), and since I don't program ruby, it
does feel unnatural, mainly because the construct is different than
everything else in the language.  With anonymous functions, at least I have
something more familiar to hold onto (and I understand better that it isn't
magic).

Cheers,
   Kevin



>
>
> 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