Re: correct way to create boiler plate code

2011-05-16 Thread dmerrio
Thanks for the formatting tips. Copy and pasting kind of messed up the formatting, not that it was good to start with. I am still developing a coding style. == Quote from bearophile (bearophileh...@lycos.com)'s article > dmerrio: > > import main; //class definition of rng > > import std.math; //tr

Re: correct way to create boiler plate code

2011-05-16 Thread dmerrio
Thank you for the reply. Potential, but there still seems to be alot of repetitive code.

Re: correct way to create boiler plate code

2011-05-16 Thread bearophile
dmerrio: > import main; //class definition of rng > import std.math; //trig functions > import std.conv; //to!double > import std.string; //toupper > > double transFunc(alias transedentalFunc)(rng aRng){ > try{return(transedentalFunc(aRng.getCellValue().coerce! > (double)));} //cellValue st

Re: correct way to create boiler plate code

2011-05-16 Thread Kai Meyer
On 05/16/2011 01:08 PM, dmerrio wrote: I am parsing some formulas from a spreadsheet file. To duplicate the behavior of the spreadsheet functions, I am having to create a lot of boiler plate code that maps from the spreadsheet functions to the built-in functions. Mixin would seem to allow me to a

Re: correct way to create boiler plate code

2011-05-16 Thread Trass3r
foreach runs at runtime, while mixin is expanded at compile time. Not the whole truth though. foreach over tuples gets unrolled at compile time so you can do stuff like: // +=, -=, ... Vector opOpAssign(string op, U)(U s) { foreach (i, _; tuple) mixin("tuple[i] " ~ op ~

Re: correct way to create boiler plate code

2011-05-16 Thread dmerrio
changing the relevent code, changes the error, but it still does not compile... immutable funcs = ["tan"]; void createFuncs(){ foreach(func; funcs){ mixin("double " ~ toupper(func) ~ "(double aReal) {return(" ~ func ~ "(aReal));}"); } } new error... Error 1

Re: correct way to create boiler plate code

2011-05-16 Thread Timon Gehr
> I am parsing some formulas from a spreadsheet file. To duplicate > the behavior of the spreadsheet functions, I am having to create a > lot of boiler plate code that maps from the spreadsheet functions > to the built-in functions. Mixin would seem to allow me to > automate the boiler-plate creati

Re: correct way to create boiler plate code

2011-05-16 Thread Trass3r
string[] funcs = ["tan"]; calling mixin a compile time has the following error... Error 1 Error: variable func cannot be read at compile time C:\D\SVNProjects\trunk\xcellD\xcell1\trig.d 22 That's because funcs is mutable. Try to make it immutable or enum.

correct way to create boiler plate code

2011-05-16 Thread dmerrio
I am parsing some formulas from a spreadsheet file. To duplicate the behavior of the spreadsheet functions, I am having to create a lot of boiler plate code that maps from the spreadsheet functions to the built-in functions. Mixin would seem to allow me to automate the boiler-plate creation, but i