[OT]new D2.0 + C++ language

bearophile bearophileHUGS at lycos.com
Sat Mar 21 07:23:22 PDT 2009


Piotrek:

> Haha, I found good discussion on reddit<

On the other hand, D too for me becomes a puzzle language when I use many string mixins or templates in functional-style. D macros will possibly improve that situation some.


> J language expample:<

K language seems worse to me, this is a full raytracer that saves in pgm (in C++ it's about 120 lines of code written in normal style):
http://www.nsl.com/k/ray/ray.k

U:{x%_sqrt x _dot x}
S:{[r;s]:[0>d:_sqr[s 1]+_sqr[b:v _dot r 1]-v _dot v:s[0]-*r;0i;0>t:b+e:_sqrt d;0i;0<u:b-e;u;t]}
I:{[r;h;o]:[~4:*o;:[~S[r;*o]<*h;h;h _f[r]/o 1];~h[0]>l:S[r]o;h;(l;U r[0]-o[0]-l*r 1)]}
T:{[r;o;d;z;l]:[0i=*h:I[r;z]o;0.;~0>g:h[1]_dot l;0.;0i=*I[(r[0]+(r[1]**h)+d*h 1;-l);z]o;-g;0.]}
N:{[n;o;i]0{x+T[(0 0 -4.;U(i+(y%4)-n%2),n);o;_sqrt 2^-42;0i,,3#0.]U -1 -3 2.}/+4_vs!16}
R:{[k;n]"P5\n",(5:n,n),"\n255\n",_ci _.5+15.9375*N[n*1.;C[k;0 -1 0.]1.]'+|@[n _vs!n*n;0;|:]}
C:{[k;c;r]:[k=1;(c;r);((c;r*3);(,(c;r)),C[k-1;;r%2]'+c+-3 3[2_vs 2 3 6 7]*r%_sqrt 12)]}
\t q:R[3]32
"temp.pgm"6:q
\"C:\\Program Files\\IrfanView\\i_view32.exe" temp.pgm

APL-like languages are a dead-end...

Bye,
bearophile



More information about the Digitalmars-d mailing list