Hello David,

Thanks for your nice help. Your idea of creating a caller function 
solved my problem.

Regards,
Leonard

On 3/20/2013 10:31, David Baelde wrote:
> Hi Leonard,
>
> Using a reference to break this circularity problem is the right
> solution. We don't have a simpler solution for now, although we have
> this in mind for a few potential language extensions.
>
> On Wed, Mar 20, 2013 at 12:38 AM, Leonard de Ruijter
> <[email protected]> wrote:
>> register_source=ref fun ()->()
>> src = input.harbor(...,on_connect=!register_source())
>> register_source:=see function above
>> I however don't know how to create the reference variable itself. I get
>> this kind of errors:
>> At line 44, char 16-17:
>>     this value has type
>>       ref((...)->unit) (infered at line 31 char 17 - line 36 char 3)
>>     but it should be a subtype of (the type of the value at line 44 char
>> 16 - line
>>    50 char 3)
>>       ref((...)->source(_))
>
> It's probably only a "small" syntax or type error. For instance, you
> cannot write !register_source(), it is understood as
> !(register_source()). Unfortunately, you cannot fix it by writing
> (!register_source)() either -- it's a rigidity of our syntax that is
> necessary to allow nice things such as not writing semicolons after
> each instruction. Finally, on_connect takes an argument but your
> register_source function does not.
>
> Long story short, I recommend writing it as follows:
>
> register_source = ref (fun () -> ())
> def call_register_source(_)
>    f = !register_source
>    f()
> end
> src = input.harbor(...,on_connect=call_register_source)
> register_source := ...
>
> Hope this helps,
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to