On 06/02/2013, at 2:46 AM, john skaller wrote:
> 
> However I found a weird bug I can't explain (in the compiler).
> 
> But this does not work:
> 
>       i = shape.decoder  ( p + slot * dynamic_slot_size, s, i);
> 
> It generates this C++:
> 
>      _i44905_v44905_i = _i44906_v44906_shape->decoder; //assign
> 
> which is a type error. Somehow the argument of the function just got lost!
> 
> What we have here is a bit interesting I admit: the function "decoder" here is
> curried:
> 
>       decoder shape ( p + slot * dynamic_slot_size, s, i)
> 
> it has type:
> 
>       gc_shape_t -> (address * +char * size --> size)
> 
> however the first arrow is a Felix function and the second arrow 
> is a C function. More interesting, decoder is given by
> 
>       fun decoder: gc_shape_t -> decoder_t = "$1->decoder";
> 
> in other words it isn't really a function, its a macro. 


And having written this I found the bug immediately: a hack I introduced
to allow you to "curry" call "macros".

So what happened is, it type checked, but it used the hack to all the decoder
function with two arguments, shape, and the tuple. But the code just uses $1 as
you can see so the second argument (the tuple) just got dropped. I deleted the 
hack
from the compiler and now it works :)

Sometimes talking at a blank wall is useful.

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to