On Tue, Feb 4, 2020 at 10:04 AM Ben Wilson wrote:
> > The code Function.constant(c) is much more expressive and descriptive
> than fn _ -> c end.
>
> To be clear, if this could work without macros, I'd be inclined to agree,
> although I recognize that there may be some who do not. My issue person
> The code Function.constant(c) is much more expressive and descriptive
than fn _ -> c end.
To be clear, if this could work without macros, I'd be inclined to agree,
although I recognize that there may be some who do not. My issue personally
is that there simply isn't any function you can write
Thanks for the discussion, all. I enjoy being here.
*Summary: I will bow out of this conversation after this one last attempt.
Feel free to skip it. *
I will say that I would use this function frequently in my teaching and in
my day-to-day code if I had it. I think it describes a concept that is
Ben,
That is how const is used in Haskell. Although without currying I don’t see how
it is useful. I’m waiting to see an example that drives it home. I agree with
Bruce about naming concepts but I don’t see the concept as useful in Elixir.
Bruce, do you have a code sample using the idea?
Amos
Addendum: I re-read the proposal because the const/1 vs const/2 thing
confused me, and I'm seeing both in play there. The spec is arity 2, the
example right after though is arity 1, and the Enum example is arity 2 but
without a constant value. The Enum example perhaps makes the most sense,
beca
I agree with Michal. Additionally, I'm not clear how `const/1` could be
used in Bruce's example at all.
To elaborate, `fn -> foo() end` and `const(foo())` cannot be equivalent
when `const/1` is merely a function. This becomes readily apparent when
`foo()` is side effects or side causes. In the
I’d argue back that this particular pattern, where you want a list of fixed
length with the same value, is much better served by `List.duplicate/2`.
I think in general, higher order combinator functions like identity, const,
flip, and friends are usually used to facilitate the point-free style o