www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - a complex question

reply dennis luehring <dl.soluz gmx.net> writes:
why can't i write something like this

float a;
float b;

a = do_something(a);
b = do_something(b);

cfloat c = (1+b) + (3*a)i

or

cfloat c = (1+do_something(a)) + (3 * do_something(b))i;

ok i know it is a syntax problem - but why?

maybe with a new syntax?

cfloat c = (1+b) + (3*a)#i

ciao dennis
Nov 19 2005
next sibling parent reply Tomás Rossi <Tomás_member pathlink.com> writes:
In article <dlnkoi$knk$1 digitaldaemon.com>, dennis luehring says...
why can't i write something like this

float a;
float b;

a = do_something(a);
b = do_something(b);

cfloat c = (1+b) + (3*a)i

or

cfloat c = (1+do_something(a)) + (3 * do_something(b))i;

ok i know it is a syntax problem - but why?

maybe with a new syntax?

cfloat c = (1+b) + (3*a)#i
Tom
Nov 19 2005
next sibling parent reply dennis luehring <dl.soluz gmx.net> writes:

other ideas to solve the problem or syntax changes cfloat c = 1*b + (a*5)i // or do nobody need this (a*5)i thing (im not an complex pro. :-)) how can i write this in d (in an clear and handy way) ciao dennis
Nov 19 2005
parent "Walter Bright" <newshound digitalmars.com> writes:
"dennis luehring" <dl.soluz gmx.net> wrote in message
news:dlnmr9$mu4$1 digitaldaemon.com...

other ideas to solve the problem or syntax changes cfloat c = 1*b + (a*5)i // or do nobody need this (a*5)i thing (im not an complex pro. :-)) how can i write this in d (in an clear and handy way)
cfloat c = 1*b + (a*5i); cfloat c = 1*b + (a*5)*1i; ifloat i = 1i; cfloat c = 1*b + (a*5)*i;
Nov 19 2005
prev sibling parent dennis luehring <dl.soluz gmx.net> writes:

sorry i can use 1i cfloat c = 1 + (2*3)*1i; cioa dennis
Nov 19 2005
prev sibling next sibling parent reply Manfred Nowak <svv1999 hotmail.com> writes:
dennis luehring wrote:

[...]
 maybe with a new syntax?
 cfloat c = (1+b) + (3*a)#i
Why is it so bad to write the usual cfloat c = (1+b) + (3*a)*1i ??? -manfred
Nov 19 2005
parent dennis luehring <dl.soluz gmx.net> writes:
im so stupid , thank your
Nov 19 2005
prev sibling parent David L. Davis <SpottedTiger yahoo.com> writes:
In article <dlnkoi$knk$1 digitaldaemon.com>, dennis luehring says...
why can't i write something like this

float a;
float b;

a = do_something(a);
b = do_something(b);

cfloat c = (1+b) + (3*a)i

or

cfloat c = (1+do_something(a)) + (3 * do_something(b))i;

ok i know it is a syntax problem - but why?

maybe with a new syntax?

cfloat c = (1+b) + (3*a)#i

ciao dennis
It can be done with a small change, see your code modified below: Output: ------------------------- C:\dmd>dmd floattest2.d C:\dmd\bin\..\..\dm\bin\link.exe floattest2,,,user32+kernel32/noi; C:\dmd>floattest2 c = (1 + b) + (3 * a) * 1.0fi; a=1.50, b=1.50, c=2.5+4.5i c = (1 + do_something(a)) + (3 * do_something(b)) * 1.0fi; do_something(a)=1.50, do_something(b)=1.50, c=2.5+4.5i C:\dmd> Hope you find this sample code useful, David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Nov 19 2005