On 9/21/07, skaller <[EMAIL PROTECTED]> wrote: > Default arguments are now implemented.
This is great. I've started to diagram out modules for os interaction that will use this. > A default argument is bound in the context > of the function, not inside the function, so may > NOT refer to other parameters (which means the type > had better not be polymorphic .. :) So no doing "fun f (a:int=1, b=a+1)"? :) Thats understandable. > > Note again: the argument MUST BE A RECORD, i.e. you > have to use named arguments for defaults to work. > You cannot supply a tuple argument which is too short > and let the defaulted tail values fill the tuple out. So, if we want to have non-named arguments, we have to define functions like ocaml's labeled functions, where the record is the first argument: fun f (a=5, b=6) (f:int->int) => ...; > Note again even more: named arguments and defaults > only apply to the FIRST argument of a curried function. > This is because the application to the second argument > is made by a closure of a child function the main > function returns, and so it is not a direct call, > and overload resolution doesn't apply. > > [snip] > > and (f 1) is an expression, so it isn't clear how to lookup > the parameter list of g from that.. this could be fixed > with a change in representation so f is represented > as written, rather than being desugared. Generally I'm fine with this restriction. However, I don't think it'd play well with the dot notation: fun foo (s:string) (a=2, b=3) => ...; "abc".foo (a=1); Aside: I noticed that there's a problem using the dot notation with integers and floats, because the lexer interprets the dot for precision. Is it worthwhile trying to get the lexer to handle "1.foo" or "1.f.foo" correctly? I guess we could enforce that if you want to write one in float you have to have a number between the dot and the 'f' as in "1.0f.foo". That should be enough to distinguish a function call and a float. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language