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

Feature request: #include statements for DSL #1332

Open
vapniks opened this issue Jun 28, 2023 · 3 comments
Open

Feature request: #include statements for DSL #1332

vapniks opened this issue Jun 28, 2023 · 3 comments
Assignees

Comments

@vapniks
Copy link
Contributor

vapniks commented Jun 28, 2023

I'm steadily building a library of functions written in the miller DSL.
It would be useful to be able to source them into my scripts with a c-style #include statement.

@johnkerl
Copy link
Owner

johnkerl commented Jun 29, 2023

@vapniks thanks for the request. I've never been eager to go this route -- C's include pattern has been (IMO) an antipattern over the years; being moved away from in other languages since, such as Java and Go; and C++ itself is moving (albeit slowly) along the module route and away from includes.

At a more concrete level, there are potential user-level confusions such as having a #include line inside curly braces, difficulty debugging when the include is in the wrong place, difficulty debugging when the include is in the intended place but the code isn't functioning as desired. Also implementation-level snags such the possibility of infinite recursion.

I've instead leaned toward library-loading: here for example:
https://miller.readthedocs.io/en/latest/reference-dsl-user-defined-functions/#loading-a-library-of-functions

If you haven't checked that out, please do! If you already have and it isn't working well for you, my preference would be to have a conversation about how to make it better fit your needs.

@johnkerl johnkerl self-assigned this Jun 29, 2023
@vapniks
Copy link
Contributor Author

vapniks commented Jun 29, 2023

Yeah, I saw that, but it means I (and anyone I share my code with) have to remember to type it on the command line every time :(

@janxkoci
Copy link

FYI there is a support for @include in GNU awk (aka gawk). The gawk manual also describes how to code the feature for other awks, to make awk libraries more portable.

I think this basic gawk-like feature would be welcome by miller users, no need for anything complicated like in C, imho.

@johnkerl johnkerl changed the title Feature request: #include statements for DSL Feature request: #include statements for DSL Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants