Comment On Alex Winston's Blog
It looks like java.net doesn't like me any more. I'm not allowed to post a comment to Alex Winston's blog:
Alex Winston's BlogComment Submission Error
Your comment submission failed for the following reasons:
You are not allowed to post comments.Posting as: weiqigao
Allowable html: a href,br/,p,b,strong,em,i,ol,ul,li,blockquote,pre
So I'll post what would have been a comment on that blog here. This is in response to a Cay Horstmann comment that reads:
Cay Horstmann: I think int plus2(int) is a non-starter. Don't entangle the declared variable within fragments of the type. That approach has been thoroughly discredited after it made a disastrous appearance in C/C++. Try writing a function that yields an int=>int function using your syntax...
@Cay, it is actually quiet simple to write such a function:
int makeAdder(int n)(int x) = int (int n)(int x) {
return int(int x) { x + n };
}
Given the above, we can have
int add7(int x) = makeAdder(7);
and
int result = add7(8); // yields 15