-
Notifications
You must be signed in to change notification settings - Fork 231
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
Documentation should be improved for propagate
and debug/stacktrace
.
#1365
Comments
Below is a demo of the remark about
Strictly speaking, I think one can read the docstring as claiming to describe the |
Looking at void janet_stacktrace_ext(/* elided */ const char *prefix) {
// elided...
int wrote_error = !prefix; // <-- NOTE 1
// elided...
for (fi = janet_v_count(fibers) - 1; fi >= 0; fi--) {
// elided...
/* Print prelude to stack frame */ // <-- NOTE 2
if (!wrote_error) {
JanetFiberStatus status = janet_fiber_status(fiber);
janet_eprintf("%s%s: %s\n",
prefix ? prefix : "",
janet_status_names[status],
errstr ? errstr : janet_status_names[status]);
wrote_error = 1; For const char *prefix = janet_optcstring(argv, argc, 2, NULL);
janet_stacktrace_ext(fiber, x, prefix); and const char *janet_optcstring(const Janet *argv, int32_t argc, int32_t n, const char *dflt) {
if (n >= argc || janet_checktype(argv[n], JANET_NIL)) {
return dflt;
}
return janet_getcstring(argv, n);
} Perhaps then the docstring could be:
|
Investigating (var [f1 f2]
[nil (coro :inside)])
(try
(error "a")
([e]
(set f1 (fiber/current))
(resume f2)
(propagate :x f2)
:unreached))
(pp [(fiber/last-value f1)
(fiber/last-value f2)]) Output was:
So it looks like the May be this gets us slightly closer to an explanation of what [1] Snooped from here. |
Looking at the bytecode instruction execution implementation of VM_OP(JOP_PROPAGATE) {
Janet fv = stack[C];
vm_assert_type(fv, JANET_FIBER);
JanetFiber *f = janet_unwrap_fiber(fv);
JanetFiberStatus sub_status = janet_fiber_status(f);
if (sub_status > JANET_STATUS_USER9) {
vm_commit();
janet_panicf("cannot propagate from fiber with status :%s",
janet_status_names[sub_status]);
}
fiber->child = f;
vm_return((int) sub_status, stack[B]);
} If we assume an invocation of Janet fv = stack[C]; corresponds to Then JanetFiber *f = janet_unwrap_fiber(fv);
JanetFiberStatus sub_status = janet_fiber_status(f); The code: vm_return((int) sub_status, stack[B]); leads to [1] the following bit of sig = run_vm(fiber, in);
}
/* Restore */
if (janet_vm.root_fiber == fiber) janet_vm.root_fiber = NULL;
janet_fiber_set_status(fiber, sig);
janet_restore(&tstate);
fiber->last_value = tstate.payload;
*out = tstate.payload;
return sig; Here, Note that: janet_fiber_set_status(fiber, sig); takes the fiber status from Also, janet_vm.return_reg = &(state->payload); Phew! So in summary, a "signal" (
[1] #define vm_return(sig, val) do { \
janet_vm.return_reg[0] = (val); \
vm_commit(); \
return (sig); \
} while (0) [2] Since janet_vm.return_reg = &(state->payload);
|
Tweak debug/stacktrace docstring (#1365)
After debug/stacktrace is done, propagate is remaining. |
The following is from the website docs:
So as I understand it, after calling
So bringing some of the pieces together, examining a portion of the docstring:
IIUC, "signal" refers to the status of the fiber (based on earlier investigation in this issue).
One can see (with a little massaging of the output): (let [_00000r (fiber/new (fn [] (error :a)) :ie)
_00000s (resume _00000r)]
(if (= (fiber/status _00000r) :error)
(do
(def e _00000s)
(def f _00000r)
(propagate e f))
_00000s)) Here:
One can see that after
Note that in general it's not necessary for the first argument to For another example, see the code in this comment. [1] fiber's typically have their "last value" this initialized to [2] Though |
Below is a candidate docstring that I think is more complete:
I think it's not unreasonable to expect people to have read relevant sections of the website docs. In the current case, I think the fibers portion is a likely place people might look given that the first sentence of the docstring mentions fibers. Further, I think (as pointed out in an earlier comment) that section of the website docs has relevant and useful information that can help to make sense of this docstring. However, I'm not sure
I might have missed other treatment in the main text, but if that is really missing, may be it would make sense to add something appropriate. |
(doc propagate) should not be an IQ test puzzle. Right now, it is. If you want people to use open-source softwares, you should improve UX. In this case, UX means clear documentation. As clear as a llama spitting in your face... Nuances and passing remarks won't do. Llama spits will do... I don't want janet to be an esoteric language. |
I'll start by saying that if you haven't read the main maintainer's comment here about the goals of the project, it might be worth trying to take that in and think over your most recent comment in light of it. Note that his comment is from a few years back and things can change over time, so grains of salt and all that. However, it might help in understanding the current state of things, so I still recommend reading it. Regarding the documenation for I will repeat a quote from Gerald Sussman here (which I have mentioned elsewhere to you) concerning his opinion on the reality of contemporary software development:
via: https://wingolog.org/archives/2018/01/11/spectre-and-the-end-of-langsec This matches a fair bit of my experience of working with a variety of programming languages. I think it's something many developers are likely to be able to relate to. It is true that I experience a certain amount of that working with Janet, but I have found it to be less so than for a number of others (including another lisp-like that I spent some years with, that has a much bigger user base AND more maintainers). As mentioned previously though, I don't think the docstrings are meant to be read in isolation. I think the expectation to consult the website docs is sound and reasonable because docstrings are not on their own a sufficient medium of expression for communicating certain kinds of information in a practical manner. I do think Janet's documentation (both the website and the docstrings) can still be improved (can you tell from the effort I (and others) are putting into it?). In the current case, I think the proposed change to
As mentioned in this comment, I think some changes to the website docs regarding [1] I wanted to get confirmation that those two functions aren't really covered that well in the main text before making an issue though. |
What? What is the value of a fiber? |
This would be the type of thing to address in the website docs as background information regarding fibers. By the way it is the "last value", not the value of the fiber. That is one of the things I mentioned above about touching on |
I think the use of "What?" at the beginning of your comments as you have been doing on more than one occasion might be interpreted as being on the uncivil side. Further, I don't believe the contexts in which it has arisen have warranted that kind of expression. Please be more considerate in your communication. |
OT. I reread those three years old comments and am happy with what we did. Thank you, @sogaiu, for mentioning it and being part of the effort! |
After finalizing j3blocks and j3blocks-extra, I finally had some attention left to read comments here. It seems that No documentation mentions something like that. I thought the error value was the signal. |
I think you are not digesting well what I have already written above. I suggest you read more carefully. I believe I have covered all of the mentioned points. |
I think that pull request in combination with #1365 (comment) can resolve this issue. |
Based on some futher information, comments, and digestion of collected info [1], I'm considering the following alternative proposal for
[1] Here are some relevant bits:
|
I think that's good. |
Thanks for taking a look. I've opened #1392 for a proposal to add to the docstring of |
My impression is that this issue has been addressed. Perhaps it can be closed. |
Here,
x
should be the first element of a tuple passed totry
'scatch
part. For example,The doc doesn't explain what
x
is.Here, the doc says both err and prefix should be absent in order for
debug/stacktrace
to omit error, but if eithererr
orprefix
is absent,debug/stracktrace
doesn't print error.The text was updated successfully, but these errors were encountered: