RE: Confirming silliness

  • From: William Adams <william_a_adams@xxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Tue, 10 Mar 2015 19:37:38 +0000

silliness confirmed, my own that is.
 
I went back to just plain old strings in a table, and it magically works.
 
I could have sworn...
 
-- William

===============================
- Shaping clay is easier than digging it out of the ground.
 
> Date: Tue, 10 Mar 2015 08:09:00 +0100
> From: mike-1503@xxxxxxxxxx
> To: luajit@xxxxxxxxxxxxx
> Subject: Re: Confirming silliness
> 
> William Adams wrote:
> > passing in the strings directly didn't seem to work in practice.
> > I don't think it can  because the ffi needs to know what to cast
> > it to (variable arguments), and it doesn't know that from the
> > function signature. It could assume 'const char *', but that may
> > or may not be correct, and thus I explicitly cast.
> 
> No, this works fine. The rules are explicitly stated here:
> 
>   http://luajit.org/ext_ffi_semantics.html#convert_vararg
> 
> > and thus I explicitly cast.                                           
> 
> Sadly so. First, this creates dangling references, which is a bad
> thing to do. Lua strings are a perfectly fine way to store the
> content of, err, strings.
> 
> Second, you could do the cast just before use to avoid the
> dangling reference. But, anyway, the cast is unnecessary.
> 
> --Mike
> 
                                          

Other related posts: