Re: Arrays oddities

  • From: Mike Pall <mike-1403@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 31 Mar 2014 11:24:39 +0200

Alain Meunier wrote:
> 1) Why can we allocate a value in an array out of the bound ?

Allocate? You mean access. The FFI is a low-level interface. It
doesn't do bounds-checking (which isn't possible on C types in
general, anyway). http://luajit.org/ext_ffi_semantics.html#policy

> 2) Should not an array be faster than a table ?

It is. If properly used in a realistic benchmark that actually
tests array accesses (which is a single-cycle op) and not the
random variations in something else (~ thousands of cycles).

--Mike

Other related posts: