Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Exporting a Lua-array #301

Open
s5bug opened this issue Aug 30, 2021 · 1 comment
Open

Exporting a Lua-array #301

s5bug opened this issue Aug 30, 2021 · 1 comment
Labels

Comments

@s5bug
Copy link

s5bug commented Aug 30, 2021

The C++ side expects { names = { "bob", "joe" } }. With a linked-list, I get incorrect results:

let names = [ "bob", "joe" ]
do
  local Nil = { __tag = "Nil" }
  local names = {
    {
      _1 = "bob",
      _2 = {
        { _1 = "joe", _2 = Nil },
        __tag = "Cons"
      }
    },
    __tag = "Cons"
  }
  return { names = names }
end

and with array,

open import "data/array.ml"
let names = from_list [ "bob", "joe" ]

The Lua code is too long to include, but names[1] evaluates to a table (with a length and backing field) instead of "bob".

@s5bug
Copy link
Author

s5bug commented Sep 3, 2021

If I have time I might try and figure out a solution to this. Ideally, the syntax to create an array "makes sense" (i.e. no function calls the user has to remember, and something like [| and |] instead) and the array is literally just a Lua array value.

Is the former possible with existing features?

Is the latter possible by just changing array.ml in prelude to not store length?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants