[racket] there must be function right after parenthesis?
On Oct 26, 2010, at 1:11 AM, kty1104 at gmail.com wrote:
> there must be function right after parenthesis?
> hello~
> while I am learning GUI programming in DrRacket,
> I don't get how string literal can be placed right after parenthesis
> such as
> (define frame (instantiate frame% ("Example")))
("Example") is attempting to evaluate the function "Example" with no arguments. You probably don't want the parens.
> (define msg (instantiate message% ("No events so far..." frame)))
> (instantiate button% ("Pause" frame (lambda (button event) (sleep 5))))
> (instantiate button% ("Ok" panel void))
> I was thought one of the scheme grammar is there must be a function right after parenthesis
> and I don't understand how such a code like
> ((func arg) arg2) works too.
That one will work if the result of (func arg) is a function. Then that result function will be evaluated using arg2. Try this:
(define (func arg-to-multiply)
(define (func-to-be-used-as-result arg)
(* arg-to-multiply arg))
func-to-be-used-as-result ; result
)
((func 3) 2)
((func 4) 2)
There are much more useful reasons to use this capability.
rac
>
> could somebody please let me know how it works?
> thanks in advanced_________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users