Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better document the usage of OOP API #256

Open
StrikerRUS opened this issue Jun 23, 2020 · 0 comments
Open

Better document the usage of OOP API #256

StrikerRUS opened this issue Jun 23, 2020 · 0 comments

Comments

@StrikerRUS
Copy link
Member

I can't find any documentation of how to use m2cgen via OOP API. If I'm not mistaken, we only have examples how to use it via functional API. However, OOP API gives more options to customize code generation. I mean, the only way to change e.g. bin_depth_threshold is to change attributes of interpretor class. I believe it is very important because in most cases we set default values just randomly to pass particular tests. For instance, refer to

# R doesn't allow to have more than 50 nested if, [, [[, {, ( calls.
# It raises contextstack overflow error not only for explicitly nested
# calls, but also if met above mentioned number of parentheses
# in one expression. Given that there is no way to control
# the number of parentheses in one expression for now,
# the following variable set to 50 / 2 value is expected to prevent
# contextstack overflow error occurrence.
# This value is just a heuristic and is subject to change in the future
# based on the users' feedback.
bin_depth_threshold = 25

Also, we may not know about different other limitations of supported languages. For example, today I learned from one recent great blog post that C# has a limit for number of local variables.

Есть неплохая библиотека на питоне m2cgen, которая позволяет экспортировать в C, C#, Dart, Go, Haskell, Java, JavaScript, PHP, PowerShell, Python, R, Ruby, Visual Basic. На выходе вы получаете готовый модуль, который может быть скомпилирован вашим любимым компилятором (т.е. без использования каких-либо dll!). С m2cgen есть некоторые ограничения на сложность (к примеру C# может уткнуться в ограничение 64 тысячи локальных переменных, можно попытаться обойти ограничение путем создания нескольких небольших процедур в замен одной большой).
https://imageman72.livejournal.com/47186.html

One can easily overcome similar limitations with the help of our mixins by inheriting them in custom class without the need to modify package source code. And it can't be done via functional API.

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

No branches or pull requests

1 participant