Giter Site home page Giter Site logo

Comments (9)

technomancy avatar technomancy commented on August 11, 2024 1

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.

from fennel.

technomancy avatar technomancy commented on August 11, 2024

Try M-x fennel-reload or C-c C-k.

from fennel.

fosskers avatar fosskers commented on August 11, 2024

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.

from fennel.

technomancy avatar technomancy commented on August 11, 2024

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.

from fennel.

fosskers avatar fosskers commented on August 11, 2024

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.

from fennel.

fosskers avatar fosskers commented on August 11, 2024

Okay, there seem to be multiple things happening here.

Setup

  1. Have a symlink to https://github.com/fosskers/transducers.fnl/blob/master/transducers.fnl in the local testing directory.
  2. Add the following to a testing file:
(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}
  1. 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)

from fennel.

fosskers avatar fosskers commented on August 11, 2024

Also try reloading with ,reload transducers in the repl;

This works, by the way (for Scenario 2).

from fennel.

technomancy avatar technomancy commented on August 11, 2024

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.

from fennel.

fosskers avatar fosskers commented on August 11, 2024

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.

from fennel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.