[racket] there must be function right after parenthesis?

From: Richard Cleis (rcleis at mac.com)
Date: Tue Oct 26 04:19:59 EDT 2010

Oops. Sorry about the first question.  I thought you meant that it did *not* work, and I didn't read enough of the code.  As CV showed, 'instantiate' is defined with special syntax. The language allows for developers to define special syntax, too. New forms are normally closely related to the language, unless you go to a lot of trouble.

rac


On Oct 26, 2010, at 1:45 AM, Richard Cleis wrote:

> 
> 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
> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.