-
Notifications
You must be signed in to change notification settings - Fork 242
Patch try to accept (try body ([] catch-body)) #1605
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
Conversation
Perhaps I don't understand it entirely, but what is the purpose of |
I use it to change the error message. For example, |
I may be missing some of what's going on in this discussion (^^; -- but below are some related thoughts. For (try
(error "hey")
([e]
(print "hi:" e))) If we don't want to have to choose a name (because we aren't going to use the information) we can do: (try
(error "hey")
([_]
(print "hi"))) but: (try
(error "hey")
([]
(print "hi"))) seems ok to me too. There's another part of the PR which is to improve the error message, which IIUC is what #1603 was originally mostly(?) about:
For the reported case, I did find the error message to be puzzling. |
For the usage, I see _ totally fine, even better to be honest. For the error, that is true, but then there are more places, where to guard it. I mean more macros. Do we want to have these guards everywhere? But I am ok with that, not the issue I had on my mind. Sorry for not being clear. Not my call anyway, just my opinion. |
Yeah, I am ok with using Just curious why you think using
It's a good question. On a somewhat related note, I wasn't so keen on this initially, but in that case it turned out later that I benefited from it repeatedly (still do occasionally!), so I am not so clear on when it's better 😅 May be for the |
It is better for me, cause it signals to me that something is omitted. TBH I love the For |
Thanks for sharing. It seems like the proposed change gives behavior that's similar to using
May be you were saying that there is something positive about the proposed behavior? Taking a closer look at [e] I presume we all know that it can have two though: [e fib] I assume that one reason it is this way is because one doesn't always want to use the associated fiber. If that's the main reasoning, it seems reasonable to me to also make Alternatively, one could have always required two elements in the tuple, i.e. With the way things are currently, In terms of not breaking things with existing code, allowing I'm even less sure about Regarding linting, do you think it would be practical for the checking to be done via flycheck? I guess not everyone uses that -- though I am saved by it quite frequently. On a related note, |
I would like to see example in
flycheck for EMACS? Not sure how to use that. |
https://janet-lang.org/docs/linting.html for the reference. |
This has been touched on elsewhere, but I believe it's pretty much a policy to not include examples in the docstrings. However, we've been adding examples to this page. (To get an idea of what this can look like, please see this portion for We can add some examples for On a side note, earlier this year a number of us made an effort to increase the coverage. There is still a lot that could be added for sure.
FWIW, there is some prose on the website for Hmm, it's interesting that the prose there seems to be describing what might be considered the behavior being proposed in this PR:
|
Ah sorry. For editor support, I've had some success getting it to work with Emacs and Neovim [1], and I think pepe had something for kakoune. May be other people have had success with other editors too. [1] For Emacs, there is at least flycheck-janet and for Neovim using nvim-lint with the following in lua << EOF
-- manually triggering -> :lua require("lint").try_lint()
require('lint').linters_by_ft = {
janet = {'janet'},
}
EOF
lua << EOF
-- TextChangedI might be worth trying at some point
vim.api.nvim_create_autocmd({ "BufRead", "BufWritePost", "InsertLeave" }, {
callback = function()
require("lint").try_lint()
end,
})
EOF
|
I've made a PR with some initial examples here. Below is how they can end up looking in a web browser on the aforementioned page. |
Nice! Are we going to accept this patch or not? |
Ultimately, I think it's up to @bakpakin. |
LGTM, esp. the addition of the improved error message. |
Fixes #1603
Also makes
(try 1 ([] (error "hi")))
valid.