[LLVMdev] LLVM-OCaml Bindings Tutorial (2.6-2.7)

Jon Harrop jon at ffconsultancy.com
Wed Feb 17 22:53:07 PST 2010


On Tuesday 16 February 2010 08:41:45 Erick Tryzelaar wrote:
> Unfortunately most errors are assertions, which we can't hook into.
> Perhaps though we can recover some type safety. Hypothetically, I can
> imagine using polymorphic variants just like lablgtk, and
>
> type llvalue = [`Value]
> type lluser = [value | `User]
> type llconstant = [user | `Constant]
> type llfunction = [llconstant | `Function]
>
> val value_name : [> llvalue] -> string
> val is_tail_call : [>llfunction] -> bool
>
> Would something like this be worthwhile? If we do it right, I think we
> could be mostly source compatible.

I thought about this before but I don't think it is worth doing. I read a blog 
post describing how one set of Haskell bindings go to great lengths to convey 
such type information but the errors it catches aren't the important ones in 
practice and the added obfuscation actually drove that user away because they 
couldn't get their code to compile and couldn't understand the type error.

I think it would be infinitely more valuable in practice to catch LLVM when it 
dies with an error and have that raised on the OCaml side as an exception so 
you get a useful stack trace telling you what your compiler was doing when 
LLVM barfed.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list