Re: [elixir-core:11638] Why no ternary expression?

2024-01-26 Thread Robert Viragh
About me: I've been learning Elixir intensively for a few months and hope to get a job as an Elixir/Phoenix developer soon. I don't have too much experience developing languages myself, I just made a YAML templating language

Re: [elixir-core:11637] Why no ternary expression?

2024-01-26 Thread José Valim
> While this works, it's also not great, because I try to avoid assignments wherever possible (being a functional language and all). Assignments do not make your code any less functional. The let form, used for assignments in many programming languages, comes from an extended version of the typed

Re: [elixir-core:11636] Why no ternary expression?

2024-01-26 Thread José Valim
One of the goals behind Elixir is to provide a certain amount of syntax that translates to a clear abstract syntax tree. The syntax available to create the language should also be available for others to extend language. Operators are generally tricky because they are hardcoded in the language.

[elixir-core:11635] Why no ternary expression?

2024-01-26 Thread Brandon Gillespie
I'm sure there's a reason, so I figured I'd ask why there isn't a ternary expression? It seems like ternary would help with the functional paradigm of Elixir. I realize one can use the `if...` as a construct, but it just isn't very readable (imho of course). Consider: some_function(

Re: [elixir-core:11635] Enhance NaiveDateTime.truncate/2 to truncate to nearest :minute or :hour

2024-01-26 Thread James Lavin
You continue to astound me with your responsiveness, José. Thank you for all you have done! Truncating and zeroing out certainly are different things, and there's no simple way to implement both perfectly. I would be thrilled to get some improvement implemented, however the community decides

Re: [elixir-core:11633] Enhance NaiveDateTime.truncate/2 to truncate to nearest :minute or :hour

2024-01-26 Thread Austin Ziegler
We've implemented a Timestamp module that defines truncate/2 as zeroing. ```elixir @doc """ Truncates the provided date or timestamp to the specified precision (`:microsecond`, `:millisecond`, `:second`, `:minute`, `:hour`, or `:day`). The given date or timestamp is returned unchanged if

Re: [elixir-core:11632] Enhance NaiveDateTime.truncate/2 to truncate to nearest :minute or :hour

2024-01-26 Thread José Valim
This is complicated because "truncate" is about removing the precision, and we cannot have a minute precision. The way to support it properly would be to allow seconds to be nil and then we would print it as "2022-12-31 13:45", without the seconds component, but I think this would be a large

[elixir-core:11632] Enhance NaiveDateTime.truncate/2 to truncate to nearest :minute or :hour

2024-01-26 Thread James Lavin
Hi: Thank you, Elixir community, for building this incredible language and ecosystem! I just had a need to truncate a NaiveDateTime to the nearest minute and was surprised to see that option isn't available. I'd like to propose something like the following (which I just typed out but haven't