On Oct 27, 8:52 am, Strom <[email protected]> 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.

>
> It's my impression that the above bind calls are equivalent given the
> way the scala compiler behaves when I call "processForm" or
> "processForm()".
>
> Also, I wasn't even sure the method itself would allow the code to
> compile.  I thought I'd have to do "() -> processForm" or "() ->
> processForm()".
>
> The error I was getting was this:
> error type mismatch
>   found : Unit
>   required : () -> Any
>
> Can someone please clarify? Thanks so much.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to