Closed fosskers closed 1 year ago
Try M-x fennel-reload
or C-c C-k
.
I had tried that, but it doesn't seem to work either. In executing sum-1
manually in the REPL or via C-c C-e
directly in the buffer (which I'm more oft to do), it is convinced that t.add
doesn't exist.
Did you reload the module that you added the function to, or the module that's calling the one that changed?
If it's the first one, it could be a bug. Can you provide a repro case? Also try reloading with ,reload transducers
in the repl; it should be the same thing as M-x fennel-reload
.
I think that the library with the function added was never actually loaded into the REPL - I guess it had only been done so transitively via the require
call to it. Let me reproduce this and get back to you.
I think that the library with the function added was never actually loaded into the REPL - I guess it had only been done so transitively via the require call to it.
There's no difference between these two situations; if a module is loaded transitively or directly it behaves the same either way.
Okay, there seem to be multiple things happening here.
(local t (require :transducers))
(fn sum-1 [tensor] "Sum the elements of a Rank-1 tensor." (t.transduce t.pass t.add tensor))
(sum-1 [1 2 3])
{:sum-1 sum-1}
3. Comment out the `add` export within the transducers file.
This is the starting setup for both scenarios below. I completely restart Emacs between each scenario to ensure a clean slate.
### Scenario 1: The REPL
1. Open testing file.
2. C-c C-k
3. Completion does not work for `t` symbol.
4. Bind this module to a local in the REPL.
5. Call sum-1 in REPL; fails, since t.add doesn't exist yet.
6. Open transducers buffer and export `add`.
7. C-c C-k once again in testing file.
8. Can call sum-1 in REPL without needing to rebind the local (convenient!)
9. But, error in REPL implying t.add is nil.
### Scenario 2: The Buffer
This is more often how I work with Lisps; local one-liners that I execute for testing without typing things in the REPL manually.
1. Open testing file.
2. Attempt C-c C-e on local one-liner for testing.
3. It fails: sum-1 is not loaded.
4. C-c C-e on sum-1: it fails, transducers hasn't been loaded.
5. C-c C-e on `require` line, then sum-1 again.
6. C-c C-e on the one-liner: fails, `add` isn't exported yet.
7. Open transducers buffer and export `add`.
8. C-c C-e on the `require` doesn't overwrite what the Lisp process already holds; `add` continues not to exist.
### Lines of Inquiry
1. Could the symlink have anything to do with it?
2. How come the REPL (the Lisp process?) seems to get in different states between `C-c C-k` and individual `C-c C-e` calls? (re: completions)
Also try reloading with
,reload transducers
in the repl;
This works, by the way (for Scenario 2).
In scenario 1, you said you're only reloading the testing file. You need to reload the file that changed in order to have the changes reflected in the repl.
In scenario 2 it sounds like you're trying to run code that refers to things that haven't been loaded yet. Re-running require
has no effect; you have to reload in order to get the new changes in a module to show.
Thanks. After playing around more last night, I think the proper mental model (and the one you're hinting at) is to use a single REPL session across multiple Fennel projects (if they're interdependent), and make sure everything is C-c C-k
'd properly.
I'll close this for now, cheers.
I'm getting more used to
fennel-mode
and enjoying myself, so thank you.I've noticed that executing
C-c C-e
(lisp-eval-defun) on arequire
line only "works" the first time. That is, if the underlying library changes and I reeval therequire
line, autocomplete doesn't show new functions, nor are they usable when I attempt to use them within the file. Here is a quick example:I had added
add
on-the-fly when I noticed+
isn't a function in Fennel, but upon reevaluating the entire buffer, I found that it was claiming thatadd
didn't exist. Indeed it was being passed tot.transduce
asnil
, in the Lua way.Any thoughts about what might be happening here? Cheers!
P.S. I would have opened this issue within the
fennel-mode
repo, but couldn't figure out how. :pray: