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

Request option to put long function calls on multiple lines #356

Open
mikechristiansenvae opened this issue May 18, 2021 · 3 comments
Open

Comments

@mikechristiansenvae
Copy link

No description provided.

@xoofx xoofx added the wontfix label May 18, 2021
@xoofx
Copy link
Member

xoofx commented May 18, 2021

This is something that we can't fix with the language.
Scriban is a dynamic language, so you can't distinguish an access to 2 variables on 2 lines from a function call:

With your request, the following existing code:

x
y

would translate to x(y) which would break all users. Also, x could be or not a function, and so you can't resolve this knowledge at compile time, you need to resolve it at runtime, hence why multiple lines is not possible.

There is a language mode (Scientific), that allows to call function calls with parenthesis, I believe that this one could be - or is already - supporting that.

@xoofx xoofx closed this as completed May 18, 2021
@mikechristiansenvae
Copy link
Author

Maybe we could go with Python's approach? In Python, you use a backslash at the end of the line. Literally, you're escaping the newline.

Scriban would count that as a newline only for the purpose of SourceSpan or reconstituting the original template. The parser would ignore that newline and treat it the same as any other non-significant whitespace.

really_long_function "This is" "a really" "long function" "call with" "lots of" "arguments that" "could really" "benefit from" "being spread" "across multiple" "lines so" "that I" "can use" "argument names" "for clarity"

Might become something like this:

really_long_function arg1: "This is"            \
                     arg2: "a really"           \
                     arg3: "long function"      \
                     arg4: "call with"          \
                     arg5: "lots of"            \
                     arg6: "arguments that"     \
                     arg7: "could really"       \
                     arg8: "benefit from"       \
                     arg9: "being spread"       \
                     arg10: "across multiple"   \
                     arg11: "lines so"          \
                     arg12: "that I"            \
                     arg13: "can use"           \
                     arg14: "argument names"    \
                     arg15: "for clarity"

@xoofx
Copy link
Member

xoofx commented May 18, 2021

Maybe we could go with Python's approach? In Python, you use a backslash at the end of the line. Literally, you're escaping the newline.

Maybe, can't tell how much work that can be, could be complicated but PR welcome (no personal time to work on this)

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

2 participants