April 18, 2008
Walter Bright wrote:
> Bill Baxter wrote:
>> For instance (this is all from my matrix/vector classes in OpenMesh/D which are basically a complete rewrite of the original C++ versions)
> 
> Got a link to your code?
> 
> (What you're doing looks pretty cool!)

It's on dsource.
http://www.dsource.org/projects/openmeshd

The snippet was from the Geometry dir:
http://www.dsource.org/projects/openmeshd/browser/trunk/OpenMeshD/OpenMesh/Core/Geometry

specifically, MatrixT:
http://www.dsource.org/projects/openmeshd/browser/trunk/OpenMeshD/OpenMesh/Core/Geometry/MatrixT.d


My other big dsource project is MultiArray.

http://www.dsource.org/projects/multiarray

I recently added DFLAT (D Flexible Linear Algebra Types) which is a port+improvements of the C++ library, FLENS.  DFLAT has templates to supports all the matrix storage types used by BLAS and LAPACK, and also the sparse matrix libraries SuperLU, TAUCS, and UMFPACK.

No CTFE there, but plenty of template logic, like here:
http://www.dsource.org/projects/multiarray/browser/trunk/multiarray/dflat/Blas.d

...which tries to take any type of matrix arguments and figure out the right BLAS call to make to multiply them together.

--bb
April 18, 2008
On 2008-04-17 23:32:03 -0400, Bill Baxter <dnewsgroup@billbaxter.com> said:

> Psst -- don't tell anyone but ...
> opDot... coming to a DMD near you soon.

opDot? I'd like to hear why it would be named this way instead of opMember, opFwd, or anything telling what usage the operator is about instead of what it looks like. There's a reason Walter has choosen opAdd, opDiv, opSlice, etc. instead of opPlus, opSlash, opBrakets, etc. and I feel it was a very good idea. Why move away from this?

I know there's a precedent (opStar), but I'd like to hear the rationale behind this choice too (why isn't it called opDeref?).

-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/

April 18, 2008
On 18/04/2008, Michel Fortin <michel.fortin@michelf.com> wrote:
>  I know there's a precedent (opStar), but I'd like to hear the rationale
> behind this choice too

I believe opStar() applied to a value will cause it to become the principle performer in a major Hollywood movie!

:-)
April 18, 2008
On Fri, 18 Apr 2008 09:15:31 -0400, Michel Fortin wrote:

> On 2008-04-17 23:32:03 -0400, Bill Baxter <dnewsgroup@billbaxter.com> said:
> 
>> Psst -- don't tell anyone but ...
>> opDot... coming to a DMD near you soon.
> 
> opDot? I'd like to hear why it would be named this way instead of opMember, opFwd, or anything telling what usage the operator is about instead of what it looks like. There's a reason Walter has choosen opAdd, opDiv, opSlice, etc. instead of opPlus, opSlash, opBrakets, etc. and I feel it was a very good idea. Why move away from this?
> 
> I know there's a precedent (opStar), but I'd like to hear the rationale
> behind this choice too (why isn't it called opDeref?).

Wouldn't it still be legal to use the asterisk as multiply or deferef? I understand the reason for +, but you really can't say * isn't both multiply and dereference.

Maybe the dot could be used as a member call, and just to say that there should be something here but don't know what. :)
April 18, 2008
janderson Wrote:

> In the past people have posted these cool algorithms/templates they figured out how to do in some neat way with D.  Things like wow, this would take INF+ lines in C++ but I can do it in 2 in D.   This seems to have died down a bit.   I always found these topics most interesting.
> 
> So I'm requesting people to post "cool stuff" they figured out how to do in D.
> 
> -Joel

I'm not sure if this is the kind of thing you're looking for, but this is a proof-of-concept template that I came up with a few days ago, inspired by a blog post describing similar functionality in Factor [1]. Completely at compile time, it parses a text file describing a mapping between an 8-bit encoding and Unicode, and builds data structures and functions to convert between that encoding and Unicode. The text files are all in a standard format, available at ftp://ftp.unicode.org/Public/MAPPINGS/

Of course, this wouldn't be a big deal to do at runtime with a module constructor, or to simply write a pre-processor to convert each text file to a D module, since they're unlikely to ever change. But I'm pretty new at D and for my own education I wanted to see if I could do all the parsing at compile time so that the full text of the file isn't stored in the executable or bundled with the software.

alias Encoding!("CP1252.txt") windows1252; // ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
auto w1 = "Trademark\x99"; // TM symbol in Windows-1252
auto u1 = "Trademark\u2122"w; // TM symbol in Unicode

wchar[] conv1 = windows1252.toU(w1);
assert(conv1 == u1);

char[]  convback = windows1252.fromU(conv1);
assert(convback == w1);

To be honest I was expecting this to be easier than it was. What I thought would be a trivial experiment ended up taking about an hour, most of that time spent trying different approaches to get CTFE to accept my code. CTFE is a wonderful feature but it's still much, much too limited in what code it will accept, in my opinion.

I've attached the ugly, proof-of-concept code for the module. Please don't think less of me after reading it. :)

[1] http://useless-factor.blogspot.com/2008/04/programming-in-series-of-trivial-one.html


April 18, 2008
Brian Palmer wrote:
> To be honest I was expecting this to be easier than it was. What I thought would be a trivial experiment ended up taking about an hour, most of that time spent trying different approaches to get CTFE to accept my code. CTFE is a wonderful feature but it's still much, much too limited in what code it will accept, in my opinion.

Agreed. CTFE is basically just an interpreter that operates on an existing syntax tree, so there's no reason nearly every feature of the language can't be supported (mutable global state + CTFE might not be a great idea, but dynamic allocation, classes, exceptions, etc. would be great to see).
April 18, 2008
Michel Fortin wrote:
> On 2008-04-17 23:32:03 -0400, Bill Baxter <dnewsgroup@billbaxter.com> said:
> 
>> Psst -- don't tell anyone but ...
>> opDot... coming to a DMD near you soon.
> 
> opDot? I'd like to hear why it would be named this way instead of opMember, opFwd, or anything telling what usage the operator is about instead of what it looks like. There's a reason Walter has choosen opAdd, opDiv, opSlice, etc. instead of opPlus, opSlash, opBrakets, etc. and I feel it was a very good idea. Why move away from this?
> 
> I know there's a precedent (opStar), but I'd like to hear the rationale behind this choice too (why isn't it called opDeref?).

Unlike opStar, opDot's name is instantly intuitive. It doesn't fit with the others, but at least it's easy to guess what it does, so it's a step up.
April 18, 2008
Robert Fraser wrote:
> Michel Fortin wrote:
>> On 2008-04-17 23:32:03 -0400, Bill Baxter <dnewsgroup@billbaxter.com> said:
>>
>>> Psst -- don't tell anyone but ...
>>> opDot... coming to a DMD near you soon.
>>
>> opDot? I'd like to hear why it would be named this way instead of opMember, opFwd, or anything telling what usage the operator is about instead of what it looks like. There's a reason Walter has choosen opAdd, opDiv, opSlice, etc. instead of opPlus, opSlash, opBrakets, etc. and I feel it was a very good idea. Why move away from this?
>>
>> I know there's a precedent (opStar), but I'd like to hear the rationale behind this choice too (why isn't it called opDeref?).
> 
> Unlike opStar, opDot's name is instantly intuitive. It doesn't fit with the others, but at least it's easy to guess what it does, so it's a step up.

It's not.. My first thought was 'dot-product?'.

L.
April 19, 2008
Michel Fortin wrote:
> On 2008-04-17 23:32:03 -0400, Bill Baxter <dnewsgroup@billbaxter.com> said:
> 
>> Psst -- don't tell anyone but ...
>> opDot... coming to a DMD near you soon.
> 
> opDot? I'd like to hear why it would be named this way instead of opMember, opFwd, or anything telling what usage the operator is about instead of what it looks like. There's a reason Walter has choosen opAdd, opDiv, opSlice, etc. instead of opPlus, opSlash, opBrakets, etc. and I feel it was a very good idea. Why move away from this?
> 
> I know there's a precedent (opStar), but I'd like to hear the rationale behind this choice too (why isn't it called opDeref?).

There was a big thread about that one too where everyone complained that it didn't make sense and violated Walter's own proclamations about how operator functions should be named.  But in the end he just ignored the debate.  Hmmm, but it looks like no one ever filed anything about it. Time to fire up bugzilla.

--bb
1 2
Next ›   Last »