March 02, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | > auto M3 = M1 ^* M2;
Maybe better:
auto M3 = M1 *^ M2;
Bye,
bearophile
|
March 02, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Era Scarecrow | On Saturday, 2 March 2013 at 00:31:20 UTC, Era Scarecrow wrote:
> On Friday, 1 March 2013 at 23:29:43 UTC, Paul D. Anderson wrote:
>>
>> My bottom line is the need to define at least one more product operator. I only propose adding it to the core language because I can't find a way to make it happen in a library. I am open to suggestions.
>
> I'd say a DSL for the scientific library would be best, likely as a mixin, then the text could be processed and use it's own rules and replace symbols with function calls?
>
> //can mix regular operations and utf extras
> a = scientificCalc!"(s * 4) × 4"(s); //possible call formats?
> mixin(scientificCalc("a = (s * 4) × 4"));
That's just what I need. Thanks.
|
March 02, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul D. Anderson | Paul D. Anderson:
> That's just what I need. Thanks.
Really? :-)
Bye,
bearophile
|
March 02, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Saturday, 2 March 2013 at 00:38:36 UTC, bearophile wrote:
>> auto M3 = M1 ^* M2;
>
> Maybe better:
>
> auto M3 = M1 *^ M2;
>
> Bye,
> bearophile
Yeah that one seems useful. Other not that much.
|
March 03, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile Attachments:
| GCC has min and max operators, and the syntax is very clever:
min = a <? b;
max = a >? b;
Ie, a shorthand of the ?: operator, in a similar way that C# has '??'
(another really nice shorthand).
On 2 March 2013 10:20, bearophile <bearophileHUGS@lycos.com> wrote:
> Maybe #* #max #min? (Also usable with a "=" prefix, #=* #=max #=min).
>>
>
> Sorry, I meant postfix:
>
> #*= #max= #min=
>
> So instead of:
>
> foo = min(foo, bar);
> foo = foo.min(bar);
>
> You write:
>
> foo #min= bar;
>
> (This syntax is generalizable to any diadic function. But I don't think D
> has to go there.)
>
>
> An alternative syntax:
>
> @* @max @min @*= @max= @min=
>
> Another alternative syntax for the second multiplication operator:
>
> auto M3 = M1 ^* M2;
>
> Having all future D scientific libraries use the same nice and clean standard operator has some advantages.
>
> Bye,
> bearophile
>
|
March 03, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul D. Anderson Attachments:
| On 2 March 2013 07:51, Paul D. Anderson < paul.d.removethis.anderson@comcast.andthis.net> wrote: > 1. They are hard to type or otherwise enter in to a text file. > I have × and ÷ on my keyboard; it's AltGr + '='/'+', no center-dot though :( I've always wanted those 2 operators! Sadly ascii just doesn't offer any sensible characters for it, and nobody seems to like unicode on code... |
March 03, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Sun, 03 Mar 2013 15:50:10 +0100, Manu <turkeyman@gmail.com> wrote: > On 2 March 2013 07:51, Paul D. Anderson <paul.d.removethis.anderson@comcast.andthis.net> wrote: >> 1. They are hard to type or otherwise enter in to a text file. > > I have × and ÷ on my keyboard; it's AltGr + '='/'+', no center-dot > though :( > I've always wanted those 2 operators! Sadly ascii just doesn't offer any > sensible characters for it, and nobody seems to like unicode on code... I do. I so desperately want to be able to use those sensible operators for mathy stuff. I *loved* seeing Fortress' list of operators, and it hurts not being able to use it. -- Simen |
March 03, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On 3/3/13 9:42 AM, Manu wrote: > GCC has min and max operators, and the syntax is very clever: > min = a <? b; > max = a >? b; > Ie, a shorthand of the ?: operator, in a similar way that C# has '??' > (another really nice shorthand). Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html Andrei |
March 03, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu:
> Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html
Do you know why?
Those <? >? look nice enough, and maybe they are worth adding to D.
But it's also useful to keep max and min as free functions because they are useful for higher-order functions (and because in D you can't give single operators to max and min):
matrix1.map!max
matrix2.map!max
matrix3.map!length
Bye,
bearophile
|
March 03, 2013 Re: Additional Binary Operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | > Those <? >? look nice enough, and maybe they are worth adding to D.
But they are not essential.
Maybe they were removed because they are too much non-standard. It's like "and" and "or": "and" and "or" are much better than "&&" and "||", but adding them to just one compiler, and keeping the older operators around, doesn't help make them popular at all.
Bye,
bearophile
|
Copyright © 1999-2021 by the D Language Foundation