On Oct 27, 8:52 am, Strom <
strommo...@gmail.com> wrote:
> I'm not sure if this is a scala or a lift related question, but when I
> try to bind a submit button, I'm having some confusion on using zero
> parameter functions as the "() -> Any" parameter in the submit
> signature.
>
> The signature for the method in question is
> SHtml.submit(value : String, func : () => Any, attrs : (String, String)
> *)
>
> 1. My first question is about the following method definitions
> def processForm () : Unit = {...}
> vs
> def processForm = {...} //no parentheses after method declaration
>
> Why can I call "processForm" as well as "processForm()" for the first
> example, but only "processForm" for the second example. If there is
> scala/lift documentation on this simple question?
Because compiler already knows that processForm is a zero argument
function and accepts processForm call. In the second example you just
can't call a call-by-name using () as it would contradict its very
definition.
>
> 2. Why do I get a compiler error when I use the following code:
> bind( ...
> "submit" -> SHtml.submit( "Process Form", processForm() ) /*type
> mismatch error*/
> )
> vs
> bind( ...
> "submit" -> SHtml.submit( "Process Form", processForm ) /*compiles
> successfully*/
> )
processForm() is a value not a function. It is the value returned by
processForm function while processForm is the function itself.