Re: [elixir-core:11746] Am I the only one confused with the receive/after pattern — it feels like an anti-pattern.

2024-05-06 Thread 'Andrey Yugai' via elixir-lang-core
In my not so long professional experience with elixir, you don't write bare receive/after, usually it comes in some form of genserver callbacks. I agree that after clause not being pattern matching is confusing, but it's a fair trade-off to keep language at least visually consistent, and also

Re: [elixir-core:11614] [Proposal] Suggestion for the "mix new" task - git support

2023-12-26 Thread 'Andrey Yugai' via elixir-lang-core
In my career I've never been in position to run `git init`, and now you want to make it completely impossible :) Original Message On 26 Dec 2023, 19:53, Jean Lima wrote: > Add git support to mix new as argument. > > With the intention of a better experience for users starting

Re: [elixir-core:11528] [proposal] Elixir For GSOC 2024

2023-09-20 Thread 'Andrey Yugai' via elixir-lang-core
I haven't checked in a while, but there aren't many issues to begin with, and they require quite a bit of context to just start digging. Some are for tracking purposes and you shouldn't submit any PR's for them Original Message On 20 Sept 2023, 16:17, Apoorv Gupta wrote: >

Re: [elixir-core:11422] [Proposal] As-patterns from haskell

2023-06-07 Thread 'Andrey Yugai' via elixir-lang-core
Could you provide an elixir example with proposed new syntax, for those who is not familiar with haskell? Original Message On 8 Jun 2023, 11:36, Corvo Liu wrote: > In haskell there's a syntax sugar called as pattern. For example: > > ``` > f (x:xs) = x:x:xs > ``` > > maybe

Re: [elixir-core:11408] [Proposal] Add function average or avg to Enum module.

2023-05-22 Thread 'Andrey Yugai' via elixir-lang-core
Whether any function is worth of stdlib is a really subtle topic, but I think it'd be helpful to try to consider why average function hasn't been added yet. >From my experience, the order on any kind of elements comes up pretty often, >thus min/max values are widely used. In the same vein sum

Re: [elixir-core:11266] [Question] :math module

2023-02-23 Thread 'Andrey Yugai' via elixir-lang-core
There's not so much elixir can do to improve erlang's :math​, it's already [implemented](https://github.com/erlang/otp/blob/master/lib/stdlib/src/math.erl)with NIFs. Rewriting it in pure elixir/erlang would only degrade performance. Other question is why doesn't :math​ have more functions? BEAM

Re: [elixir-core:11236] [Proposal] Add macro is_real_map

2023-01-03 Thread 'Andrey Yugai' via elixir-lang-core
There's also an option of pattern matching any struct, not exactly a guard, but changing your code a bit shouldn't be a problem ``` def foo(%_{} = _struct), do... def foo(map) when is_map(map), do... ``` Sent from Proton Mail mobile Original Message On 4 Jan 2023, 04:03,

Re: [elixir-core:11208] Reason for DateTime not includes larger units like minutes, hours, days?

2022-12-12 Thread 'Andrey Yugai' via elixir-lang-core
I think larger units were added since 1.14, but if you cannot upgrade for some reason, Timex has a nice API: `Timex.shift(dt, months: 1, days: 4.5, minutes: -30, seconds: 50)` Sent from Proton Mail mobile Original Message On 12 Dec 2022, 20:21, Daniel Kukuła wrote: > Hi -

Re: [elixir-core:11030] [Proposal] Add "into" keyword to ecto query expression

2022-08-31 Thread 'Andrey Yugai' via elixir-lang-core
I wouldn't claim this is a good idea because `into` in your example looks like leakage of app logic into DB level. If you're only ought to create user id - user map, it is pretty easy to do in Elixir from just a list of users. If you concerned about memory/time, you could try streaming from

Re: [elixir-core:10952] `Map.get/3` to return default value for `nil` value

2022-06-22 Thread 'Andrey Yugai' via elixir-lang-core
led my `Map.get/3` would be > better. > > `Map.get(map, key, default_value)` looks better than `Map.get(map, key) || > default_value` > > On Wed, Jun 22, 2022 at 11:32 AM 'Andrey Yugai' via elixir-lang-core > wrote: > >> For this behavior I think you'd be better of

Re: [elixir-core:10950] `Map.get/3` to return default value for `nil` value

2022-06-22 Thread 'Andrey Yugai' via elixir-lang-core
For this behavior I think you'd be better of using `map[key] || default_value`, or even `Map.get(map, key) || default_value`. Docs for `Map.get/3` are pretty clear about when it returns default value. Original Message On 22 Jun 2022, 14:25, Nganga Mburu wrote: > I've found

Re: [elixir-core:10936] [Proposal] Add Enum.none?/2

2022-06-18 Thread 'Andrey Yugai' via elixir-lang-core
I think negated `Enum.any?` should be equal to `Enum.none?` in all cases. Also do you have an example where `Enum.none?` would be useful? Original Message On 18 Jun 2022, 17:35, Zvonimir Rudinski wrote: > Seeing Enum.all?/2 being available made me assume there was also an >

Re: [elixir-core:10922] [Proposal] Add Tuple.replace_at

2022-06-10 Thread 'Andrey Yugai' via elixir-lang-core
Hi Rudolf. Elixir actually has such wrapper already, and what's more cool about it, it's implemented exactly how you suggested: https://github.com/elixir-lang/elixir/blob/a64d42f5d3cb6c32752af9d3312897e8cd5bb7ec/lib/elixir/lib/kernel.ex#L1724 Other tuple related functions are mentioned at the

Re: [elixir-core:10917] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread 'Andrey Yugai' via elixir-lang-core
ks, Randson From: 'Andrey Yugai' via elixir-lang-core Sent: 07 June 2022 16:38 To: elixir-lang-core@googlegroups.com Subject: Re: [elixir-core:10916] [Proposal] List.delete support for delete multiple fields inside a list Hey Randson, have you seen `Enum.filter`? It does almost exactly what

Re: [elixir-core:10915] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread 'Andrey Yugai' via elixir-lang-core
Hey Randson, have you seen `Enum.filter`? It does almost exactly what you want, except for any enumerable, not just list. Original Message On 7 Jun 2022, 18:31, Randson < orand...@gmail.com> wrote: Currently, the function `List.delete` only works for a single field. What I

Re: [elixir-core:10909] [Proposal] Support for shorter @spec syntax

2022-06-02 Thread 'Andrey Yugai' via elixir-lang-core
I don't think there's much gain in fiddling with Elixir internals trying to modify special form, or writing new macro specifically to omit the left argument in `::/2` for function specs. Perhaps more profoundly, this would implicitly tie one spec to one function clause, which is kinda odd if

Re: [elixir-core:10866] [Proposal] Macro.camelize support lower camel case

2022-04-11 Thread 'Andrey Yugai' via elixir-lang-core
Hey there, I think that would be a nice addition in general, but [Macro.camelize/1](https://hexdocs.pm/elixir/Macro.html#camelize/1) has a very specific purpose: > This function was designed to camelize language identifiers/tokens, that's > why it belongs to the