skaller wrote:
> On Wed, 2006-11-08 at 18:28 +1100, Jonathan Kelly wrote:
>   
>> Hi,
>>
>> I'm trying to wrap "signal" like this ...
>>
>> //------------------
>> const SIGINT:int = "SIGINT";
>> proc signal:int*(int->void) = "signal($1, $2)";
>>    
>> proc finish(sig:int) {
>>     C_hack::ignore(endwin());
>>     print$ f"finish got signal %d\n" sig;
>>     C_hack::ignore(gc());
>>     System::exit(0);
>> }  
>>    
>> signal(SIGINT, finish);
>> //------------
>>
>> but I get this error message, and I don't know what it means...
>>
>> $ flx -I./nc nc/nc.flx
>> CLIENT ERROR
>> [bind_expression] Simple name finish binds to function set in
>> nc/nc.flx: line 20, cols 16 to 21
>> In nc/nc.flx: line 20, cols 16 to 21
>> 19:
>> 20: signal(SIGINT, finish);
>>     
>
> 'finish' is the name of a set of overloaded functions,
> not the name of a single function.
>
> The name of the function is 
>
>       finish of (int)
>
> If there is only one function in the set, you can also use
>
>       the finish
>
> as the name:
>
>       signal(SIGINT, the finish);
>
> This will break if you introduce another overload called
> 'finish' into the scope. The more explicit name
>
>       signal(SIGINT, finish of (int));
>
> will only break if you introduce another function
>
>       fun finish: int -> ..
>
> into the scope. When doing a function call:
>
>       finish 1
>
> you don't need this because overload resolution calculates
> which function it is for you, based on the argument type.
>
> You might think it could do that from context in:
>
>       signal(SIGINT, finish);
>
> too, but the problem is the type of signal's argument
> is used for overload resolution, so it has to be known.
>
>
>   
I keep forgetting about signature when passing functions ... in this 
example changing it to
signal(SIGINT, finish of (int));


comes up with

$ flx -I./nc nc/nc.flx
nc/nc.cpp: In member function `virtual flx::rtl::con_t* 
flxusr::nc::_init_::resume()':
nc/nc.cpp:90: error: cannot convert `flxusr::nc::_pt6605*' to `void 
(*)(int)' for argument `2' to `void (* signal(int, void (*)(int)))(int)'
nc/nc.cpp:91: error: expected `;' before '}' token


as erik noted....

Jonathan.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to