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

Spacing and newline edits #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonocarroll
Copy link

Feel free to ignore this - I just wanted to play around with it and see if I could fix a very minor annoyance.

With this toy vapour code

func foo(a: int = 1, b: char = "", c:char = ""): int {
    return paste(b, c, a)
}

let bar: int = foo(0, "Hello, ", "World!")

I get this result

[email protected]

foo = function(a = 1,b = "",c = "") {
return(paste(b, c, a)
)
}
bar = foo(0, "Hello, ", "World!")

With the minor changes in this PR, I get

[email protected]

foo = function(a = 1, b = "", c = "") {
return(paste(b, c, a))
}
bar = foo(0, "Hello, ", "World!")
  • spaces after each term in the function signature
  • no newline breaking the return()

I have not tested what else this changes or if this is even the right place to make these changes. Actually, I'm fairly sure it's not for the extra newline; it happens for other functions containing expressions, too.

One option would be to style the generated R file with e.g. {styler} which would take care of any inconsistencies from transpilation, e.g. dealing with indentation which sounds like a whole world of trouble. Running styler::style_file("R/vapour.R") over the file generated by [email protected] produces

foo <- function(a = 1, b = "", c = "") {
  return(paste(b, c, a))
}
bar <- foo(0, "Hello, ", "World!")

which appears to have fixed both issues.

@JohnCoene
Copy link
Contributor

Sorry for commenting on this so late!

The reason for the (too) numerous line breaks is partially an issue I have in parser #29 which I will look into soon.

I did some thinking about the transpiler and realise we would just need to add indentation \t when we enclose an environment. I think we can already get much cleaner code.

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

Successfully merging this pull request may close these issues.

2 participants