Re: [elixir-core:9374] PROPOSAL: Nil-safe Access.at/1

2020-02-08 Thread Greg Vaughn
On Feb 8, 2020, at 6:34 PM, José Valim wrote: > > Also, I should have asked this sooner, but can't the complex path that you > are writing be easily expressed with pattern matching? Can your use cases use pattern matching too? Since you asked, my primary use of Kernel.get_in is when I have

Re: [elixir-core:9373] PROPOSAL: Nil-safe Access.at/1

2020-02-08 Thread José Valim
To be honest, I am not sure either. I am not sold on Access.path/1 as a name. Using "path" makes it sound like it is a general abstraction but it isn't. Passing an Access.path to put_in or update_in won't make them suddenly accept nils because in there it is a more complex problem (you need to

Re: [elixir-core:9372] PROPOSAL: Nil-safe Access.at/1

2020-02-08 Thread Greg Vaughn
I'm uncertain how best to proceed at this point. I have some code that is a proof of concept of what I believe is a compromise. I don't wish to open another PR prematurely and have it closed, so I'll try one more round of discussion here. I have added 2 new Access functions: path/1 and

Re: [elixir-core:9371] Proposal: Allow neg_integer_index in Tuple.insert_at and Tuple.delete_at

2020-02-08 Thread José Valim
Hi Kensei! So the reason we don’t allow negative indexes for tulles is because we would have to support them on elem/2 but if we do so it can’t work on guards (at least not efficiently). Also, as the docs for Tuple says, you should really really avoid index access for tuples. Pattern matching is

[elixir-core:9371] Proposal: Allow neg_integer_index in Tuple.insert_at and Tuple.delete_at

2020-02-08 Thread Kensei N
Hi ! I propose modifing Tuple.insert_at/3 and Tuple.delete_at/2 to allow neg_integer index, like Enum.at/3 Specifically, I would like to fix as below. (and delete insert_at and delete_at from elixir_rewrite.erl) @spec insert_at(tuple, integer, term) :: tuple def insert_at(tuple, index,