[elixir-core:8003] Add <*> to the list of parseable operators

2018-05-17 Thread Stas Versilov
Hello! I'am developing a matrix manipulation library for Elixir (https://github.com/versilov/matrex) and it would be really nice to have <*> operator, so that it could be overriden for matrices dot product (or element-wise multiplication). Is it possible to add it? -- You received this messag

Re: [elixir-core:8003] Add <*> to the list of parseable operators

2018-05-17 Thread José Valim
Hi Stas, Given that we already have <|>, I don't see a problem with adding <*>. My only question is why choose dot product to have an operator? Wouldn't matrex end-up requiring other operators anyway? If we add <*>, how would those other operators look like in terms of consistency? *José Valimw

Re: [elixir-core:8005] Add <*> to the list of parseable operators

2018-05-17 Thread Stas Versilov
The problem is that other math operators used on matrices are only in element-wise form (+, -, /, *), so, usual math operators are enough for this. But multiplication can be element-wise or dot-product, hence, we need two separate operators. I saw Swift guys using <*> for dot-product, seemed li

Re: [elixir-core:8005] Add <*> to the list of parseable operators

2018-05-17 Thread José Valim
Thanks for the clarification. Let's go ahead and add <*>. Regardless of this use case, I think it fits the current set of custom operators. *José Valimwww.plataformatec.com.br Founder and Director of R&D* On Thu, May 17, 2018 at 12:42 PM, Stas Versilov wrote:

Re: [elixir-core:8007] Add <*> to the list of parseable operators

2018-05-17 Thread Stas Versilov
Many thanks! Should I open an issue on GitHub or something? On Thursday, May 17, 2018 at 2:52:36 PM UTC+4, José Valim wrote: > > Thanks for the clarification. > > Let's go ahead and add <*>. Regardless of this use case, I think it fits > the current set of custom operators. > > > > *José Valimww

Re: [elixir-core:8007] Add <*> to the list of parseable operators

2018-05-17 Thread Michał Muskała
I wonder if it would make sense to have a whole suite of <_> wrapped math operators. I could imagine, for example, the Decimal library implementing them and you could import to the decimal calculations easily without sacrificing the regular math operators. Michał. On 17 May 2018, 12:52 +0200,

Re: [elixir-core:8008] Add <*> to the list of parseable operators

2018-05-17 Thread José Valim
Michał, I think the issue with your proposed approach is precedence. <+> and <*> need to have different precedences and where should we put those operators compared to all others? *José Valimwww.plataformatec.com.br Founder and Director of R&D* On Thu, May 17,

Re: [elixir-core:8009] Add <*> to the list of parseable operators

2018-05-17 Thread Michał Muskała
On 17 May 2018, 13:13 +0200, José Valim , wrote: > Michał, I think the issue with your proposed approach is precedence. <+> and > <*> need to have different precedences and where should we put those > operators compared to all others? > That's a good point. What if we put them at the same leve

Re: [elixir-core:8010] Add <*> to the list of parseable operators

2018-05-17 Thread José Valim
It would but it is worth saying we are adding a new rule that we don't have right now. Today all custom operators currently have the same precedence: https://github.com/elixir-lang/elixir/blob/master/lib/elixir/src/elixir_parser.yrl#L68 *José Valimwww.plataformatec.com.br

Re: [elixir-core:8012] Add <*> to the list of parseable operators

2018-05-17 Thread Stas Versilov
For my application (and for Decimal also) the same precedence as traditional math would be the key success factor of the new operators. Lower precedence (as now for custom operators) would be counter-intuitive, cause hardly detectable errors in calculations and lead to excessive use of brackets,

Re: [elixir-core:8012] Add <*> to the list of parseable operators

2018-05-17 Thread José Valim
Let's go with this proposal then: <+>, <->, <*> and with the same precedence as the math equivalents. *José Valimwww.plataformatec.com.br Founder and Director of R&D* On Thu, May 17, 2018 at 2:27 PM, Stas Versilov wrote: > For my application (and for Decimal

Re: [elixir-core:8013] Add <*> to the list of parseable operators

2018-05-17 Thread Michał Muskała
On 17 May 2018, 14:29 +0200, José Valim , wrote: > Let's go with this proposal then: <+>, <->, <*> and with the same > precedence as the math equivalents. > I believe this might not be enough for the matrix library, because it would need to multiplications - for dot product and cross product.

Re: [elixir-core:8015] Add <*> to the list of parseable operators

2018-05-17 Thread Stas Versilov
I planned to use "raw" +,-,/ and * for element-wise operations and <*> for dot product. But yes, it's always nice to have some options like <@>, as Michal suggests. It could also be great to have ./ and .* for element-wize, like in MathLab/Octave, but this syntactic sugar is not worth the confus