Nice TWiki > Dev > FeatureProposals > PartialApplicationSyntax (r1.1) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Dev . { Changes | Index | Search | Go }
Imported from SourceForge? RFE #672069

Background:

Many functional languages provide "curried" functions, of the form a -> b -> c, rather than the more typical (in Nice) (a,b) -> c. I think providing curried functions by default causes much confusion (and obscure error messages), so I think Nice's approach is good. But curried functions are often handy too.

Feature:

It would be good to have a compact syntax for partially applying a function. I'll suggest '_' and '...' as the symbols to use, where '_' means "omit this argument" and '...' means "omit all remaining arguments". So, for example:

String greet(String salutation, String adjective, String object) = salutation + ", " + adjective + " " + object;

test()
{
   (String, String)->String helloFun = greet("Hello", ...); //Fill first param only
   String->String helloWorldFun = helloFun(_, "world"); //Skip first param
   String message = helloWorldFun("currified"); 
   println(message);         //prints "Hello, currified world"
}

Which would be equivalent to:

test()
{
   (String, String)->String helloFun = (String adjective, String object) => greet("Hello", adjective, object));

   String->String helloWorldFun = String adjective => helloFun(adjective, "world");

   String message = helloWorldFun("currified");
   println(message);    //prints "Hello, currified world"
} 
-- BrynKeller? - 13 Feb 2003

Topic PartialApplicationSyntax . { Edit | Attach | Ref-By | Printable | Diffs | r1.14 | > | r1.13 | > | r1.12 | More }
Revision r1.1 - 13 Feb 2003 - 21:34 GMT - TWikiGuest
Parents: WebHome > FeatureProposals
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.