neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
471 stars 76 forks source link

Why need name while calling DoChunk? #98

Closed zhangjiejia closed 5 years ago

zhangjiejia commented 5 years ago

Can someone tell me, why need name while calling DoChunk?

neolithos commented 5 years ago

The name is used for the debug information.

zhangjiejia commented 5 years ago

Thanks, but when I use a empty string, it throw io exception, why?

neolithos commented 5 years ago

Because I test in the most cases for String.IsNullOrEmpty.

The name is imported for the debug information, but it could also be a place holder like unknown.lua.

PR is welcome, to set a dummy name if the name is empty.

zhangjiejia commented 5 years ago

So you mean that it will write debug info to harddisk? What if I don't need debug? I just run a small script like "return 1 + 1"

neolithos commented 5 years ago

Not to the harddisk, but into the memory. If you set the compile options to null, it will not generate debug information at all. But the current implementation enforces a name, because otherwise the exception will be more confusing.

For such short expression you should also investigate CreateLambda.

zhangjiejia commented 5 years ago

Thanks, I understand now