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
Thank you for the reply. Potential, but there still seems to be
alot of repetitive code.
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
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
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 ~
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
> 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
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.
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