www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Additional Binary Operators

reply "Paul D. Anderson" <paul.d.removethis.anderson comcast.andthis.net> writes:
Operator overloading in D is straightforward and sensible.

I think there is an opportunity for D to do better with some very 
small changes.

I propose including additional Unicode mathematical symbols as 
recognized operators for opBinary. All that would be required is 
to extend the lexer to recognize the symbols as binary operators.

For example, in vector arithmetic there are two different 
products defined -- the dot product and the cross product. Most 
implementations I've seen overload '*' for the inner product, but 
omit operator for the cross product. In UTF-8 the "middle dot", 
('•', \u00B7) and "multiplication sign", ('×', \u00D7), 
correspond to the more usual mathematical notation for the dot 
and cross products, respectively.

UTF-16 has many more mathematical symbols, particularly on the 
2200-22FF and 2A00-2AFF code pages. \u2207 is a wedge, commonly 
used for outer products. The circled plus (u\2A01) and circled 
times sign (\2A02) are defined for some mathematical operations. 
\u2A33 is the "smash product" symbol, which I've never heard of 
before but it sounds cool.

I am NOT suggesting that we include ALL these mathematical 
symbols as operators. If it was up to me I'd include just the 
middle dot, the cross product and the wedge product, but YMMV.

These new operators would need a precedence. Since most of these 
are product operators the precedence should be the same as '*' or 
"/".

Pros:
1. Extends the capability to define mathematical operators for 
user-defined types
2. Shouldn't break any existing code since the symbols aren't 
valid chars in identifiers (as far as I can tell) and aren't 
being used elsewhere.
3. Takes advantage of the existing opBinary overloading so 
implementation should be straightforward.

Cons:
1. They are hard to type or otherwise enter in to a text file.
2. They may not display correctly in some output forms.
3. They could be confusing to someone unfamiliar with the concept.

With regard to the difficulty of entering or displaying these 
characters, I think that is largely because modern computer 
languages only give lip service to Unicode -- code is almost 
exclusively written in ASCII. I have seen one instance where a 
certain mathematical constant was named 'Ï€', but the author was 
an iconoclast and pariah.
Mar 01 2013
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Paul D. Anderson:

 I am NOT suggesting that we include ALL these mathematical 
 symbols as operators. If it was up to me I'd include just the 
 middle dot, the cross product and the wedge product, but YMMV.
If you want to introduce new standard operators, I suggest to keep their number very low. And I suggest to avoid Unicode symbols. The operators I find useful for me are one more product operator, a max infix operator and a min infix operator. Bye, bearophile
Mar 01 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:


Sorry, I meant postfix: 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
Mar 01 2013
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
 auto M3 = M1 ^* M2;
Maybe better: auto M3 = M1 *^ M2; Bye, bearophile
Mar 01 2013
parent "deadalnix" <deadalnix gmail.com> writes:
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.
Mar 02 2013
prev sibling parent reply Manu <turkeyman gmail.com> writes:
GCC has min and max operators, and the syntax is very clever:
  min = a <? b;
  max = a >? b;

(another really nice shorthand).


On 2 March 2013 10:20, bearophile <bearophileHUGS lycos.com> wrote:



 Sorry, I meant postfix:



 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
Mar 03 2013
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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;

 (another really nice shorthand).
Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html Andrei
Mar 03 2013
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
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
Mar 03 2013
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
 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
Mar 03 2013
prev sibling parent "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Sunday, 3 March 2013 at 22:58:02 UTC, bearophile wrote:
 Andrei Alexandrescu:

 Gone. 
 http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html
Do you know why?
Probably because they were non-standard, but don't look non-standard. It's not fun finding them in code that you want to compile with a different compiler...
Mar 03 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On Mar 3, 2013 9:41 PM, "Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org>
wrote:
 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;

 (another really nice shorthand).
Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html Andrei
And good riddance too. Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Mar 03 2013
prev sibling next sibling parent Manu <turkeyman gmail.com> writes:
Nooooooo!
Why would they! ;)

Well I still think they're a great shorthand.


On 4 March 2013 07:38, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org>wrote:

 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;

 (another really nice shorthand).
Gone. http://gcc.gnu.org/onlinedocs/**gcc/Deprecated-Features.html<http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html> Andrei
Mar 03 2013
prev sibling parent "deadalnix" <deadalnix gmail.com> writes:
On Sunday, 3 March 2013 at 21:38:44 UTC, Andrei Alexandrescu 
wrote:
 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;

 has '??'
 (another really nice shorthand).
Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html Andrei
I see nothing about the ?:, and it is indeed useful (or the ?? in
Mar 04 2013
prev sibling next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 03/01/2013 01:51 PM, Paul D. Anderson wrote:

 In UTF-8 the "middle dot", ('•', \u00B7) and
 "multiplication sign", ('×', \u00D7)
[...]
 UTF-16 has many more mathematical symbols
Sorry to pick on this unrelated issue but UTF-8 and UTF-16 are just Unicode encodings. Unicode itself defines all of those characters and they can all be represented in any encoding. Ali
Mar 01 2013
next sibling parent "Paul D. Anderson" <paul.d.removethis.anderson comcast.andthis.net> writes:
On Friday, 1 March 2013 at 22:09:15 UTC, Ali Çehreli wrote:
 On 03/01/2013 01:51 PM, Paul D. Anderson wrote:

 In UTF-8 the "middle dot", ('•', \u00B7) and
 "multiplication sign", ('×', \u00D7)
[...]
 UTF-16 has many more mathematical symbols
Sorry to pick on this unrelated issue but UTF-8 and UTF-16 are just Unicode encodings. Unicode itself defines all of those characters and they can all be represented in any encoding. Ali
Yes, you are correct.
Mar 01 2013
prev sibling parent Tony <askme nospam.net> writes:
In article <kgr8ub$1nc7$1 digitalmars.com>, acehreli yahoo.com says...
 
 On 03/01/2013 01:51 PM, Paul D. Anderson wrote:
 
  > In UTF-8 the "middle dot", ('•', \u00B7) and
  > "multiplication sign", ('×', \u00D7)
 
 [...]
 
  > UTF-16 has many more mathematical symbols
 
 Sorry to pick on this unrelated issue but UTF-8 and UTF-16 are just 
 Unicode encodings. Unicode itself defines all of those characters and 
 they can all be represented in any encoding.
 
 Ali
Unicode is indeed an encoding. Same for ASCII, EBCDIC, ISO 8859-X, FIELDATA, etc. The clue is in the name and term: UniCODE and enCODEing. The CODEs are unique numbers associated with each character. UTF-Xs are transformation formats. While it is not strictly incorrect to call the UTFs encodings, it is probably best avoided for better clarity. The use of the word "encoding" to mean "coded character set" goes way back. Unicode, of course, has some very specific and extensive, if not confusing, terminology and one should go there to get the story straight from the horse's mouth, but I was just chiming in to to note that "encoding" is short for "coded character set" and Unicdode is exactly that, at it's core.
Mar 17 2013
prev sibling next sibling parent reply "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Friday, 1 March 2013 at 21:52:00 UTC, Paul D. Anderson wrote:
 Operator overloading in D is straightforward and sensible.

 I think there is an opportunity for D to do better with some 
 very small changes.

 I propose including additional Unicode mathematical symbols as 
 recognized operators for opBinary. All that would be required 
 is to extend the lexer to recognize the symbols as binary 
 operators.

 For example, in vector arithmetic there are two different 
 products defined -- the dot product and the cross product. Most 
 implementations I've seen overload '*' for the inner product, 
 but omit operator for the cross product. In UTF-8 the "middle 
 dot", ('•', \u00B7) and "multiplication sign", ('×', \u00D7), 
 correspond to the more usual mathematical notation for the dot 
 and cross products, respectively.

 UTF-16 has many more mathematical symbols, particularly on the 
 2200-22FF and 2A00-2AFF code pages. \u2207 is a wedge, commonly 
 used for outer products. The circled plus (u\2A01) and circled 
 times sign (\2A02) are defined for some mathematical 
 operations. \u2A33 is the "smash product" symbol, which I've 
 never heard of before but it sounds cool.
 Pros:
 1. Extends the capability to define mathematical operators for 
 user-defined types
 2. Shouldn't break any existing code since the symbols aren't 
 valid chars in identifiers (as far as I can tell) and aren't 
 being used elsewhere.
 3. Takes advantage of the existing opBinary overloading so 
 implementation should be straightforward.

 Cons:
 1. They are hard to type or otherwise enter in to a text file.
 2. They may not display correctly in some output forms.
 3. They could be confusing to someone unfamiliar with the 
 concept.
In windows (x86, could include dos & linux?) you can hold down the alt key and manually type in the value of the character; But it seems to truncated to 8 bits so Alt+321 = 65 which is A, so likely unless you're copy/pasting the symbols it probably won't work.
 With regard to the difficulty of entering or displaying these 
 characters, I think that is largely because modern computer 
 languages only give lip service to Unicode -- code is almost 
 exclusively written in ASCII. I have seen one instance where a 
 certain mathematical constant was named '?', but the author was 
 an iconoclast and pariah.
Those operators seem more useful for scientific math. I wouldn't want them added to to the core language though. ASCII can be typed with (almost) any keyboard and use any editor (new or old); You can still read source code if outputted to a dumb terminal rather than getting odd symbols (whitespace as well) and may be tearing your hair out wondering what this UTF-8 symbol is or what it means.
Mar 01 2013
next sibling parent FG <home fgda.pl> writes:
On 2013-03-01 23:56, Era Scarecrow wrote:
   Those operators seem more useful for scientific math. I wouldn't want them
 added to to the core language though.

   ASCII can be typed with (almost) any keyboard and use any editor (new or
old);
 You can still read source code if outputted to a dumb terminal rather than
 getting odd symbols (whitespace as well) and may be tearing your hair out
 wondering what this UTF-8 symbol is or what it means.
Gotta grab that old APL keyboard from the attic...
Mar 01 2013
prev sibling parent reply "Paul D. Anderson" <paul.d.removethis.anderson comcast.andthis.net> writes:
On Friday, 1 March 2013 at 22:56:27 UTC, Era Scarecrow wrote:
  Those operators seem more useful for scientific math. I 
 wouldn't want them added to to the core language though.
I agree that they are not going to be used by most programmers. This is true for a lot of Phobos, which is sensible because modules can be imported or not, as need be. 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.
Mar 01 2013
parent reply "Era Scarecrow" <rtcvb32 yahoo.com> writes:
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"));
Mar 01 2013
next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Sat, Mar 02, 2013 at 01:31:19AM +0100, 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"));
+1. With D's compile-time capabilities, DSLs give you arbitrarily complex custom syntax at essentially zero runtime cost. You can even implement compile-time DSL optimizers that produce optimized code like no overloaded operator ever can. T -- Who told you to swim in Crocodile Lake without life insurance??
Mar 01 2013
parent reply Marco Leise <Marco.Leise gmx.de> writes:
Am Fri, 1 Mar 2013 16:36:07 -0800
schrieb "H. S. Teoh" <hsteoh quickfur.ath.cx>:

 +1. With D's compile-time capabilities, DSLs give you arbitrarily
 complex custom syntax at essentially zero runtime cost. You can even
 implement compile-time DSL optimizers that produce optimized code like
 no overloaded operator ever can.
 
 
 T
Oh my fucking god. That means you can generate complex matrix-vector interactions "on the spot" without ever using temporary matrices or vectors and the inevitable cost of leaving the FPU and rounding to float! That's brilliant. -- Marco
Mar 04 2013
next sibling parent reply "jerro" <a a.com> writes:
 Oh my fucking god. That means you can generate complex
 matrix-vector interactions "on the spot" without ever using
 temporary matrices or vectors and the inevitable cost of
 leaving the FPU and rounding to float! That's brilliant.
You can also do this using expression templates, and there are C++ libraries that do this. Of course, expression templates should also be much easier to implement in D than they are in C++.
Mar 04 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
jerro:

 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
Mar 04 2013
parent reply Marco Leise <Marco.Leise gmx.de> writes:
Am Mon, 04 Mar 2013 23:36:29 +0100
schrieb "bearophile" <bearophileHUGS lycos.com>:

 jerro:
 
 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
It's not as easy to do without C++'s convoluted constructor lookup rules. The clean approach of D makes it impossible to call a constructor implicitly like they do on the Wikipedia page about expression templates. But the approach with a small DSL looks ok, too. Not quite as seamless as the C++ version though. -- Marco
Mar 04 2013
next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Mar 05, 2013 at 12:17:06AM +0100, Marco Leise wrote:
 Am Mon, 04 Mar 2013 23:36:29 +0100
 schrieb "bearophile" <bearophileHUGS lycos.com>:
 
 jerro:
 
 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
It's not as easy to do without C++'s convoluted constructor lookup rules. The clean approach of D makes it impossible to call a constructor implicitly like they do on the Wikipedia page about expression templates. But the approach with a small DSL looks ok, too. Not quite as seamless as the C++ version though.
[...] The advantage of using DSLs is that you are free of syntax constraints in the hosting language. For example, you can add different symbols for dot product, cross product, transpose operator, etc., without being restricted by the operators that D allows you to overload. D's mixins allow you to transform such expressions into D code in non-trivial ways to achieve maximum performance in spite of the ease of writing it. T -- Shin: (n.) A device for finding furniture in the dark.
Mar 04 2013
prev sibling next sibling parent "deadalnix" <deadalnix gmail.com> writes:
On Monday, 4 March 2013 at 23:17:33 UTC, Marco Leise wrote:
 Am Mon, 04 Mar 2013 23:36:29 +0100
 schrieb "bearophile" <bearophileHUGS lycos.com>:

 jerro:
 
 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
It's not as easy to do without C++'s convoluted constructor lookup rules. The clean approach of D makes it impossible to call a constructor implicitly like they do on the Wikipedia page about expression templates. But the approach with a small DSL looks ok, too. Not quite as seamless as the C++ version though.
You can use alias this to create implicit conversion.
Mar 04 2013
prev sibling next sibling parent reply Artur Skawina <art.08.09 gmail.com> writes:
On 03/05/13 00:23, H. S. Teoh wrote:
 On Tue, Mar 05, 2013 at 12:17:06AM +0100, Marco Leise wrote:
 Am Mon, 04 Mar 2013 23:36:29 +0100
 schrieb "bearophile" <bearophileHUGS lycos.com>:

 jerro:

 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
They are trivial to implement, i even gave you an example in the past: http://forum.dlang.org/post/mailman.1195.1344699986.31962.digitalmars-d puremagic.com
 It's not as easy to do without C++'s convoluted constructor
 lookup rules. The clean approach of D makes it impossible to
 call a constructor implicitly like they do on the Wikipedia
 page about expression templates.
 But the approach with a small DSL looks ok, too. Not quite as
 seamless as the C++ version though.
[...] The advantage of using DSLs is that you are free of syntax constraints
One problem with string-based DSLs is scoping - they only work properly when mixed in into the current scope. auto c = mixin(myDSL!"a?:+:b"); mixin myDSL!("c", "a?:+:b"); mixin (myDSL!("c", "a?:+:b")); // etc is sometimes enough, but often the code would be clearer w/o the mixin. artur
Mar 05 2013
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
jerro, Marco Leise, H. S. Teoh:

 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
Artur Skawina:
 They are trivial to implement, i even gave you an example in 
 the past:

 http://forum.dlang.org/post/mailman.1195.1344699986.31962.digitalmars-d puremagic.com
My memory is not perfect, and I don't remember that example. I will take a look, thank you. Bye, bearophile
Mar 05 2013
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 5 March 2013 at 13:17:52 UTC, bearophile wrote:
 jerro, Marco Leise, H. S. Teoh:

 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
Artur Skawina:
 They are trivial to implement, i even gave you an example in 
 the past:

 http://forum.dlang.org/post/mailman.1195.1344699986.31962.digitalmars-d puremagic.com
My memory is not perfect, and I don't remember that example. I will take a look, thank you. Bye, bearophile
SciD also uses them: http://forum.dlang.org/post/drwsjxtqxcdpwdbjojgq forum.dlang.org
Mar 05 2013
prev sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Tuesday, 5 March 2013 at 12:40:32 UTC, Artur Skawina wrote:
 One problem with string-based DSLs is scoping - they only work 
 properly when mixed in into the current scope.

    auto c = mixin(myDSL!"a?:+:b");
    mixin myDSL!("c", "a?:+:b");
    mixin (myDSL!("c", "a?:+:b"));
    // etc

 is sometimes enough, but often the code would be clearer w/o 
 the mixin.
Perhaps the mixin ( mixin?) could be moved to a function's signature as an attribute? Then the compiler knows it's going to be mixed in and removes the need to do it yourself; Mind you it would have to return a string to be valid; Or it would be part of the base signature instead. string myDSL(string) mixin; mixin string myDSL(string); //now without the mixin.. auto c = myDSL!("a?:+:b"); This seems like it would be an easy thing to add and shouldn't complicate the language any.
Mar 05 2013
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Mar 05, 2013 at 01:40:19PM +0100, Artur Skawina wrote:
 On 03/05/13 00:23, H. S. Teoh wrote:
 On Tue, Mar 05, 2013 at 12:17:06AM +0100, Marco Leise wrote:
 Am Mon, 04 Mar 2013 23:36:29 +0100
 schrieb "bearophile" <bearophileHUGS lycos.com>:

 jerro:

 Of course, expression templates should also be much easier
 to implement in D than they are in C++.
I don't remember seeing them implemented in D, so far. Bye, bearophile
They are trivial to implement, i even gave you an example in the past: http://forum.dlang.org/post/mailman.1195.1344699986.31962.digitalmars-d puremagic.com
[...] Very nice!! I like the way you use alias parameters to alleviate the need for C++-style expression-tree-simulation templates. Very clever! Yet another D feature that I haven't fully appreciated the full power of. T -- Nothing in the world is more distasteful to a man than to take the path that leads to himself. -- Herman Hesse
Mar 05 2013
prev sibling parent reply "Araq" <rumpf_a gmx.de> writes:
On Monday, 4 March 2013 at 21:58:34 UTC, Marco Leise wrote:
 Am Fri, 1 Mar 2013 16:36:07 -0800
 schrieb "H. S. Teoh" <hsteoh quickfur.ath.cx>:

 +1. With D's compile-time capabilities, DSLs give you 
 arbitrarily
 complex custom syntax at essentially zero runtime cost. You 
 can even
 implement compile-time DSL optimizers that produce optimized 
 code like
 no overloaded operator ever can.
 
 
 T
Oh my fucking god. That means you can generate complex matrix-vector interactions "on the spot" without ever using temporary matrices or vectors and the inevitable cost of leaving the FPU and rounding to float! That's brilliant.
It's slightly amusing you keep re-inventing Nimrod, albeit poorly: http://build.nimrod-code.org/docs/manual.html#term-rewriting-macros
Mar 04 2013
parent "Don" <turnyourkidsintocash nospam.com> writes:
On Monday, 4 March 2013 at 23:29:09 UTC, Araq wrote:
 On Monday, 4 March 2013 at 21:58:34 UTC, Marco Leise wrote:
 Am Fri, 1 Mar 2013 16:36:07 -0800
 schrieb "H. S. Teoh" <hsteoh quickfur.ath.cx>:

 +1. With D's compile-time capabilities, DSLs give you 
 arbitrarily
 complex custom syntax at essentially zero runtime cost. You 
 can even
 implement compile-time DSL optimizers that produce optimized 
 code like
 no overloaded operator ever can.
 
 
 T
Oh my fucking god. That means you can generate complex matrix-vector interactions "on the spot" without ever using temporary matrices or vectors and the inevitable cost of leaving the FPU and rounding to float! That's brilliant.
It's slightly amusing you keep re-inventing Nimrod, albeit poorly: http://build.nimrod-code.org/docs/manual.html#term-rewriting-macros
My talk on this topic in the first D conference was in 2007. It seems Nimrod only dates from 2009. There's nothing new here.
Mar 05 2013
prev sibling parent reply "Paul D. Anderson" <nobody hotmail.com> writes:
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.
Mar 01 2013
parent "bearophile" <bearophileHUGS lycos.com> writes:
Paul D. Anderson:

 That's just what I need. Thanks.
Really? :-) Bye, bearophile
Mar 01 2013
prev sibling next sibling parent Manu <turkeyman gmail.com> writes:
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 =C3=97 and =C3=B7 on my keyboard; it's AltGr + '=3D'/'+', 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...
Mar 03 2013
prev sibling parent =?iso-8859-15?Q?Simen_Kj=E6r=E5s?= <simen.kjaras gmail.com> writes:
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 =D7 and =F7 on my keyboard; it's AltGr + '=3D'/'+', no center-d=
ot =
 though :(
 I've always wanted those 2 operators! Sadly ascii just doesn't offer a=
ny =
 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 f= or = mathy stuff. I *loved* seeing Fortress' list of operators, and it hurts= = not being able to use it. -- = Simen
Mar 03 2013