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

In the translator, consider using gsub("%S", "") instead of gsub("%S", " ") #277

Closed
hugomg opened this issue Jul 21, 2020 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@hugomg
Copy link
Member

hugomg commented Jul 21, 2020

If we remove the non-whitespace characters instead of simply replacing them with spaces it might produce more pleasant-looking output. For example,

function f(x: integer)

could become

function (x)

instead of

function f(x         )

Column numbers would not be preserved but line numbers would still be preserved. I think this might be OK. IIRC, Lua error messages don't show column numbers, they only show line numbers.

@hugomg hugomg changed the title Consider using gsub("%S", "") insstead of gsub("%S", "") Consider using gsub("%S", "") insstead of gsub("%S", " ") Jul 21, 2020
@hugomg hugomg changed the title Consider using gsub("%S", "") insstead of gsub("%S", " ") Consider using gsub("%S", "") instead of gsub("%S", " ") Jul 21, 2020
@hugomg hugomg changed the title Consider using gsub("%S", "") instead of gsub("%S", " ") In the translator, consider using gsub("%S", "") instead of gsub("%S", " ") Jul 21, 2020
@hugomg hugomg added the enhancement New feature or request label Jul 21, 2020
itssamuelrowe added a commit that referenced this issue Aug 6, 2020
… " ")`

Fixes issue #277. If we remove the non-whitespace characters instead of simply replacing them with
spaces it produces a more pleasant-looking output. For example,

```
function f(x: integer)
```

becomes

```
function (x)
```

instead of

```
function f(x         )
```

Column numbers are not be preserved but line numbers are. This is okay because Lua error messages
do not show column numbers, they only show line numbers.
itssamuelrowe added a commit that referenced this issue Aug 7, 2020
… " ")`

Fixes issue #277. If we remove the non-whitespace characters instead of simply replacing them with
spaces it produces a more pleasant-looking output. For example,

```
function f(x: integer)
```

becomes

```
function (x)
```

instead of

```
function f(x         )
```

Column numbers are not be preserved but line numbers are. This is okay because Lua error messages
do not show column numbers, they only show line numbers.
itssamuelrowe added a commit that referenced this issue Aug 7, 2020
… " ")`

Fixes issue #277. If we remove the non-whitespace characters instead of simply replacing them with
spaces it produces a more pleasant-looking output. For example,

```
function f(x: integer)
```

becomes

```
function (x)
```

instead of

```
function f(x         )
```

Column numbers are not be preserved but line numbers are. This is okay because Lua error messages
do not show column numbers, they only show line numbers.
itssamuelrowe added a commit that referenced this issue Aug 7, 2020
… " ")`

Fixes issue #277. If we remove the non-whitespace characters instead of simply replacing them with
spaces it produces a more pleasant-looking output. For example,

```
function f(x: integer)
```

becomes

```
function (x)
```

instead of

```
function f(x         )
```

Column numbers are not be preserved but line numbers are. This is okay because Lua error messages
do not show column numbers, they only show line numbers.
@hugomg
Copy link
Member Author

hugomg commented Aug 10, 2020

Fixed by #303.

@hugomg hugomg closed this as completed Aug 10, 2020
@bjornbm
Copy link
Contributor

bjornbm commented Mar 19, 2023

Column numbers would not be preserved but line numbers would still be preserved. I think this might be OK. IIRC, Lua error messages don't show column numbers, they only show line numbers

I was about to write an issue suggesting the original behavior, to get the column numbers. For “cheap” editor support, I am considering running --emit-lua and then, for example, run luacheck on the lua file(s) and use this to drive the editor (for example, [neo]vim quickfix functionality). Maybe lua-ls (sumneko) could be jury-rigged to be useful for Pallene in a similar fashion (roundtripping via --emit-lua).

Also, the fact that Lua itself doesn't show column numbers is perhaps an implementation detail that could change in the future?

Anyway, in my opinion not much was won by removing the spaces, while potential for some tooling reuse was lost. If the more pleasant-looking output is important maybe keep --emit-lua as it is and add --emit-lua-preserve-columns?

@hugomg
Copy link
Member Author

hugomg commented Mar 19, 2023

Hmm, now that's an use case I something I hadn't thought about!

I suppose that a command flag to tell pallenec to only type-check the program, without emitting a C or Lua file, might be helpful. I cooked up a quick one over on PR #566. Could you please check if it is useful for your purposes?

As for the column numbers in --emit-lua, maybe it's useful if there are extra error messages you can get from luacheck but not from pallenec. Please feel free to experiment with it and create a PR if it turns out to be a good idea. (I do like the current pleasant-looking output though, so my vote is for a separate flag or configuration option). I only ask that if you do so, open a new issue instead of commenting on this one. It's easier for me to find the discussion if it's under a recent and open issue.

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

No branches or pull requests

2 participants