One way to solve that is to add a dummy arg and use parentheses. It seems that the precedence of the ! operator is different in ocaml.

1
2
3
let walls () = ref [||]
let get_wall i j = (!walls()).(i).(j);;
By on 2/26/2008 10:19 AM ()

This can be further simplified by removing the dummy variable. So, it would simply become:

1
2
let walls = ref [||];;
let get_wall i j = (!walls).(i).(j)

The dummy variable is only necessary for preventing errors if typing each line separately into the interpreter (FSI). If using an editor like VS 2005/2008, it is not required as the type checker will be able to use successive functions/usage for type inference.

Regards,

z.

By on 2/26/2008 11:24 AM ()

I still get an error using your way zakaluka. A value restriction.
--edit--
Im a bad reader... you used floating constraints later...ok

:$

By on 2/26/2008 11:56 AM ()

Problem solved.

Thank you both. :)

By on 2/26/2008 11:44 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper