Good morning Martin, On Mon, Jun 20, 2011 at 4:50 PM, Martin Hamant <[email protected]> wrote: > btw, I don't want to "change" out, I want to "update" it. This is my > understanding of how partial out() works and maybe this is what I don't > understand.
I'll try to clarify this bit. Let's say out has type (format,source)->source. The variable out denotes a function object which expects two arguments. When I write out(%mp3) I have an expression of type (source)->source, which evaluates to a new, different function object expecting only one argument. Nothing has changed for the initial function object, and not even for the variable out -- this is maybe what isn't clear to you. # For the sake of the example let me define a dummy out. out = fun (f,s) -> s out(%mp3,blank()) # At this point out still denotes the initial function. # Indeed, we can re-use it. out(%wav,sine()) In your example you're redefining out, which gives a different impression. Leaving the if-then-else aside for now, you have something like that: out = fun (f,s) -> s out = out(%mp3) out = out(blank()) But in this code you're only changing the local definition of the variable out, not changing the object it denotes. You're only stacking up new definitions of out, each new definition being bound to a value built from the value of the previous binding. This will probably be clearer if I perform the following change which is always valid with definitions (valid in the sense that it is rigorously equivalent after parsing): if you have an expression of the form (x = v ; e) where e is the scope of the definition of x, and y doesn't occur in e, you can change it to (y = v ; e[y/x]), where e[y/x] is e where y replaces x. Concretely, the above example becomes, after two applications of this renaming operation: out = fun (f,s) -> s out' = out(%mp3) out'' = out'(blank()) This is rigorously the same as before except that we now have distinct names for the distinct definitions. Finally, to insist on the fact that we didn't change the objects, note that we can add a fourth line in that example, containing for example out(%wav,sine()), ie. use the first function object, which is still the same as on the 1st definition. Don't hesitate to keep digging into those issues, I really enjoy that kind of discussion. Cheers, David ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Savonet-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/savonet-users
