Computer Science Canada O'Caml TYS: many functions... one default |
Author: | wtd [ Sat Jan 10, 2009 4:47 am ] | ||
Post subject: | O'Caml TYS: many functions... one default | ||
Let's say I want to have a bunch of functions that take a default value.
Now, what if I want to change that default? I'd have to edit the code in several places. Figure out a way that I can change that default uniformly across both functions, without having to modify the functions themselves. Storing the default as a separate let binding doesn't count. |
Author: | sw2wolf [ Fri Nov 18, 2011 10:42 pm ] |
Post subject: | Re: O'Caml TYS: many functions... one default |
let defVal = 42 let foo ?(bar=defVal) () = bar *3 |
Author: | wtd [ Sat Nov 26, 2011 10:49 pm ] |
Post subject: | RE:O\'Caml TYS: many functions... one default |
Good on you for trying, but I disqualified that approach in the original post. |
Author: | Aange10 [ Sat Nov 26, 2011 11:42 pm ] |
Post subject: | RE:O\'Caml TYS: many functions... one default |
Oh come on wtd, it took two years for somebody to gut up and answer. Cut 'em some slack |
Author: | Tony [ Sat Nov 26, 2011 11:59 pm ] | ||
Post subject: | RE:O\'Caml TYS: many functions... one default | ||
can I use an inverse of a function? I.e., something like
|
Author: | wtd [ Mon Nov 28, 2011 1:03 am ] | ||
Post subject: | RE:O\'Caml TYS: many functions... one default | ||
|