March 05, 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>:
>
>> 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.
March 05, 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:
>> 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.



March 05, 2013
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
March 05, 2013
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
March 05, 2013
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
March 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:
> > 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
March 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.
March 18, 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.
> 
> 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.
1 2 3 4
Next ›   Last »