~technomancy/fennel

1

Re: Ignoring _ in let

Details
Message ID
<87a7bsqdkc.fsf@hagelb.org>
DKIM signature
missing
Download raw message
Benaiah Mischenko <benaiah@mischenko.com> writes:

> The use case for this would be a simple way of doing side effects
> mid-let. That probably doesn't sound like a great pitch at first, but
> it really comes in handy when debugging. I already use _ for this
> purpose, but the fact that it binds a local makes this usage less than
> ideal and has already bit me a few times.

I frequently use this for side-effects mid-let too, but I've never run
into any problems arising from the fact that a local was bound. Can you
explain what kind of issues you've run into?

-Phil

Re: Ignoring _ in let

Details
Message ID
<87y2zbz5m3.fsf@hector.i-did-not-set--mail-host-address--so-tickle-me>
In-Reply-To
<87a7bsqdkc.fsf@hagelb.org> (view parent)
DKIM signature
missing
Download raw message
Phil Hagelberg <phil@hagelb.org> writes:

> Benaiah Mischenko <benaiah@mischenko.com> writes:
>
>> The use case for this would be a simple way of doing side effects
>> mid-let. That probably doesn't sound like a great pitch at first, but
>> it really comes in handy when debugging. I already use _ for this
>> purpose, but the fact that it binds a local makes this usage less than
>> ideal and has already bit me a few times.
>
> I frequently use this for side-effects mid-let too, but I've never run
> into any problems arising from the fact that a local was bound. Can you
> explain what kind of issues you've run into?
>
> -Phil

The most recent case was https://github.com/bakpakin/Fennel/issues/174,
which was admittedly more of a bug in _ than in let.

I was also under the impression that _ was not actually bound when used
in each - i.e. (each [_ x (ipairs [3 4 5])] (print x)) - which would
have made this a more consistent behavior for let, but I was mistaken.

Given the bugfix to match and the current behavior of each, perhaps it's
less confusing to leave it as is and just expect the _ to remain unused
if it's being used as a placeholder. It's already commonly used this way
in Lua without any special dispensation from the language.

- Benaiah Mischenko