Optimisation of unpackCString#

Don Stewart dons at galois.com
Tue Apr 29 17:59:17 EDT 2008


igloo:
> On Mon, Apr 28, 2008 at 02:00:38PM -0700, Donald Bruce Stewart wrote:
> > 
> > This goes back to an old gripe of mine actually -- we can't get
> > at the length of a C string literal at compile time either, which
> > would be super useful in rules.
> 
> I think that this is easy to do by, instead of desugaring
> 
>     "foo" -> unpackCString# "foo"#
> 
> desugaring
> 
>     "foo" -> unpackCStringLen# 3# "foo"#
> 
> where
> 
>     unpackCStringLen# _ = unpackCString#
> 
> It's not really feasible to do head#, tail# etc this way, though, so if
> head#/tail# are done another way then it's probably best to do length#
> that way too.
> 
> By the way, please do file tickets for the issues from this thread, so
> that the issues and ideas don't get forgotten about!

I'd be fine with just having unpackCStringLen# (assuming the 
string is also still null terminated too).

- Don


More information about the Glasgow-haskell-users mailing list