lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 09/12/2015 09:38, Dibyendu Majumdar wrote:
> Thanks very much for trying out Ravi and for reporting above issues. I
> have not yet tried using Luarocks but I will have a look at the issues
> and try to resolve them.

Thank you!

> Does SILE create a lot of Lua functions dynamically?

No, but it does call the same very small functions hundreds of thousands
of times. The most complex routines are in here:

I tried compiling all of those in advance, using
  for k,v in pairs(SILE.linebreak) do ravi.compile(v) end
but again, it did not speed anything up.

> I'd be interested to know what auto options you tried out.

I just did

> So for best results the compiler needs to be helped by annotating
> types.

Ah. It's a shame there isn't a backward compatible way to do this. :(
Could we not have a ravi.annotate() function which could be initialized
to a dummy function in plain Lua?

Also, I guess another problem is that SILE makes heavy use of objects -
table elements rather than plain variables - and I can't see a way to
annotate table members. i.e. I would like to be able to do:

_length = std.object {
  length : number = 0,
  stretch : number = 0,
  shrink : number = 0,

I've tried doing a few annotations, but without being able to annotate
table members it all goes wrong quite quickly. e.g.:

  local pi:integer
  pi = n.penalty or 0

core/break.lua:101: Invalid assignment: integer expected near 'end'

Actually n.penalty is an integer, but I can't annotate it as such.

> Each Lua function goes into its own module (compilation unit) in LLVM
> at present - this makes each function autonomous and therefore garbage
> collectible - but this is not optimum usage of memory. I need to work
> on putting multiple functions in a module; but this would mean that
> the module cannot be collected until all functions in it are
> collected.

It would be helpful to be able to declare a bunch of functions as
related. I tend to put related functions in a table for this purpose,
and that's a pretty common object oriented programming style. So you
might have a way to compile a table full of functions as a unit.