D - a few idea from the for low level programing
- laudas cosmosc.com (44/44) Apr 19 2004 Idea 1:
- Ilya Minkov (13/25) Apr 19 2004 It has been put off till a later version of the spec, it's just not the
Idea 1: Hi guy's just looking over the speck's for D wonder if you would allow a fuction to return, more than one item, I know in and out or inout dos it, but still not very clean as you sill have to make a return value some where. as a example... using out. int frednerd( in int som_value, out int wast_of_space_and_time ); main() { int error_status, wast_of_space_and_time; error_status = frednerd( som_value, wast_of_space_and_time ); if( error_status == ERROR || wast_of_space_and_time > TOBIG ) fixproblem( wast_of_space_and_time ); read( wast_of_space_and_time ); } // Compair with this so much simpler. int, int frednerd( in int some_value ); main() { if( r1.frednerd( some_value ) == ERROR || r2.frednerd > TOBIG ) fixproblem( r2.frednerd ); read( r2.frednerd ); } is not that some much better to read ? and easy to code ? r1... r2 to be the return value's and r1.fuction_name to access them, what could be simpler ? you could use some other opterator. you also add return value name's in fuction decration's like.. int error, int read_value frednerd( in int some_value ); so it become's if( error.frednerd( some_value ) == ERROR || read_value.frednerd > TOBIG ) fixproblem( read_value.frednerd ); the compiler can hanle the life of the return value, in most case it's a int or pionter, etc.. and will end up being returned in a register. Idea 2: expose the Carry flag's on int opertions so you easy check for over flow if( (a + b).Carry ) // or some way of access the C,process flags. printf("over flow") also be nice for bit shifing... for a rowtate. a = (a << 1) | .Carry; or perhaps a = a <<C 1; Just my two cent's of idea. Lachlan Audas laudas cosmosc.com
Apr 19 2004
laudas cosmosc.com schrieb:Idea 1: Hi guy's just looking over the speck's for D wonder if you would allow a fuction to return, more than one item, I know in and out or inout dos it, but still not very clean as you sill have to make a return value some where.It has been put off till a later version of the spec, it's just not the time to think of it because 1.0 is coming near, and it's important to freeze a spec which would not make feel sorry later. So new features are probably not getting in. Now is the last chance to correct already in-spec features, should they be faulty anywhere. So far someone did a very simple set of tuple templates. Members can be acessed by .a, .b, .c and so on in order. If you can't figure it out how to write one, i shall write one again and post up.Idea 2: expose the Carry flag's on int opertions so you easy check for over flow if( (a + b).Carry ) // or some way of access the C,process flags. printf("over flow")Ah, this is interesting. Let's wait to see what Walter says about it. Since all back-ends are based on C compilers, it might not be possible or easy to implement this now, so it is likely to be postponed. -eye
Apr 19 2004