digitalmars.D - Additional Binary Operators
- Paul D. Anderson (43/43) Mar 01 2013 Operator overloading in D is straightforward and sensible.
- bearophile (10/13) Mar 01 2013 If you want to introduce new standard operators, I suggest to
- bearophile (17/19) Mar 01 2013 Sorry, I meant postfix:
- bearophile (4/5) Mar 01 2013 Maybe better:
- deadalnix (2/7) Mar 02 2013 Yeah that one seems useful. Other not that much.
- Manu (6/25) Mar 03 2013 GCC has min and max operators, and the syntax is very clever:
- Andrei Alexandrescu (3/8) Mar 03 2013 Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html
- bearophile (12/13) Mar 03 2013 Do you know why?
- bearophile (7/9) Mar 03 2013 But they are not essential.
- Peter Alexander (4/8) Mar 03 2013 Probably because they were non-standard, but don't look
- Iain Buclaw (7/16) Mar 03 2013 And good riddance too.
- Manu (4/13) Mar 03 2013 Nooooooo!
- deadalnix (4/13) Mar 04 2013 I see nothing about the ?:, and it is indeed useful (or the ?? in
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (6/9) Mar 01 2013 Sorry to pick on this unrelated issue but UTF-8 and UTF-16 are just
- Paul D. Anderson (2/11) Mar 01 2013 Yes, you are correct.
- Tony (11/26) Mar 17 2013 Unicode is indeed an encoding. Same for ASCII, EBCDIC, ISO 8859-X, FIELD...
- Era Scarecrow (13/52) Mar 01 2013 In windows (x86, could include dos & linux?) you can hold down
- FG (2/8) Mar 01 2013 Gotta grab that old APL keyboard from the attic...
- Paul D. Anderson (8/10) Mar 01 2013 I agree that they are not going to be used by most programmers.
- Era Scarecrow (8/12) Mar 01 2013 I'd say a DSL for the scientific library would be best, likely
- H. S. Teoh (8/22) Mar 01 2013 +1. With D's compile-time capabilities, DSLs give you arbitrarily
- Marco Leise (8/15) Mar 04 2013 Oh my fucking god. That means you can generate complex
- jerro (3/7) Mar 04 2013 You can also do this using expression templates, and there are
- bearophile (4/6) Mar 04 2013 I don't remember seeing them implemented in D, so far.
- Marco Leise (10/19) Mar 04 2013 It's not as easy to do without C++'s convoluted constructor
- H. S. Teoh (11/30) Mar 04 2013 [...]
- deadalnix (2/19) Mar 04 2013 You can use alias this to create implicit conversion.
- Artur Skawina (11/33) Mar 05 2013 They are trivial to implement, i even gave you an example in the past:
- bearophile (6/16) Mar 05 2013 My memory is not perfect, and I don't remember that example. I
- John Colvin (3/20) Mar 05 2013 SciD also uses them:
- Era Scarecrow (12/20) Mar 05 2013 Perhaps the mixin (@mixin?) could be moved to a function's
- H. S. Teoh (10/28) Mar 05 2013 [...]
- Araq (3/19) Mar 04 2013 It's slightly amusing you keep re-inventing Nimrod, albeit poorly:
- Don (3/25) Mar 05 2013 My talk on this topic in the first D conference was in 2007. It
- Paul D. Anderson (2/15) Mar 01 2013 That's just what I need. Thanks.
- bearophile (4/5) Mar 01 2013 Really? :-)
- Manu (6/7) Mar 03 2013 I have =C3=97 and =C3=B7 on my keyboard; it's AltGr + '=3D'/'+', no cent...
- =?iso-8859-15?Q?Simen_Kj=E6r=E5s?= (11/18) Mar 03 2013 ny =
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
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
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
auto M3 = M1 ^* M2;Maybe better: auto M3 = M1 *^ M2; Bye, bearophile
Mar 01 2013
On Saturday, 2 March 2013 at 00:38:36 UTC, bearophile wrote:Yeah that one seems useful. Other not that much.auto M3 = M1 ^* M2;Maybe better: auto M3 = M1 *^ M2; Bye, bearophile
Mar 02 2013
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
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
Andrei Alexandrescu:Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.htmlDo 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
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
On Sunday, 3 March 2013 at 22:58:02 UTC, bearophile wrote:Andrei Alexandrescu: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...Gone. http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.htmlDo you know why?
Mar 03 2013
On Mar 3, 2013 9:41 PM, "Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote:On 3/3/13 9:42 AM, Manu wrote:And good riddance too. Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';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
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
On Sunday, 3 March 2013 at 21:38:44 UTC, Andrei Alexandrescu wrote:On 3/3/13 9:42 AM, Manu wrote:I see nothing about the ?:, and it is indeed useful (or the ?? inGCC 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
Mar 04 2013
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 symbolsSorry 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
On Friday, 1 March 2013 at 22:09:15 UTC, Ali Çehreli wrote:On 03/01/2013 01:51 PM, Paul D. Anderson wrote:Yes, you are correct.In UTF-8 the "middle dot", ('•', \u00B7) and "multiplication sign", ('×', \u00D7)[...]UTF-16 has many more mathematical symbolsSorry 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
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. AliUnicode 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
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
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
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
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
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:+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??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
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. TOh 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
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
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
Am Mon, 04 Mar 2013 23:36:29 +0100 schrieb "bearophile" <bearophileHUGS lycos.com>:jerro: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. -- MarcoOf 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
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>:[...] 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.jerro: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.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
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>:You can use alias this to create implicit conversion.jerro: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.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
On 03/05/13 00:23, H. S. Teoh wrote:On Tue, Mar 05, 2013 at 12:17:06AM +0100, Marco Leise wrote: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.comAm 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, bearophileOne 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. arturIt'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
Mar 05 2013
jerro, Marco Leise, H. S. Teoh:Artur Skawina: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, bearophileThey 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.comMy memory is not perfect, and I don't remember that example. I will take a look, thank you. Bye, bearophile
Mar 05 2013
On Tuesday, 5 March 2013 at 13:17:52 UTC, bearophile wrote:jerro, Marco Leise, H. S. Teoh:SciD also uses them: http://forum.dlang.org/post/drwsjxtqxcdpwdbjojgq forum.dlang.orgArtur Skawina: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, bearophileThey 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.comMy memory is not perfect, and I don't remember that example. I will take a look, thank you. Bye, bearophile
Mar 05 2013
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
On Tue, Mar 05, 2013 at 01:40:19PM +0100, Artur Skawina wrote:On 03/05/13 00:23, H. S. Teoh wrote:[...] 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 HesseOn Tue, Mar 05, 2013 at 12:17:06AM +0100, Marco Leise wrote: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.comAm 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
Mar 05 2013
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>:It's slightly amusing you keep re-inventing Nimrod, albeit poorly: http://build.nimrod-code.org/docs/manual.html#term-rewriting-macros+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. TOh 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.
Mar 04 2013
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: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.Am Fri, 1 Mar 2013 16:36:07 -0800 schrieb "H. S. Teoh" <hsteoh quickfur.ath.cx>:It's slightly amusing you keep re-inventing Nimrod, albeit poorly: http://build.nimrod-code.org/docs/manual.html#term-rewriting-macros+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. TOh 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.
Mar 05 2013
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:That's just what I need. Thanks.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
Paul D. Anderson:That's just what I need. Thanks.Really? :-) Bye, bearophile
Mar 01 2013
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
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:ot =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=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