Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 06:41
    pepe commented #683
  • 02:34
    sogaiu commented #683
  • 02:28
    sogaiu commented #683
  • 01:57
    crocket commented #683
  • 01:33
    crocket commented #683
  • 00:18
    uvtc commented #683
  • Apr 15 23:18
    andrewchambers commented #683
  • Apr 15 23:13
    sogaiu commented #683
  • Apr 15 19:58
    bakpakin closed #682
  • Apr 15 19:58

    bakpakin on master

    Fix #682 - Don't hardcode size … (compare)

  • Apr 15 16:03
    uvtc commented #683
  • Apr 15 04:20
    sogaiu commented #683
  • Apr 15 04:10
    pyrmont commented #683
  • Apr 15 03:54
    crocket edited #683
  • Apr 15 03:53
    crocket opened #683
  • Apr 15 00:18
    bakpakin closed #678
  • Apr 12 19:11
    littleli commented #533
  • Apr 12 12:56
    sogaiu opened #116
  • Apr 12 01:28
    bakpakin labeled #682
  • Apr 11 00:13
    DEADB17 edited #682
Saikyun
@Saikyun
that way you wouldn't mess too much with the current environment, while still having access to the global namespaces table :)
Michael Camilleri
@pyrmont
Yeah. I think that's how the root environment basically works.
Like if you look at the environment for the current fiber, it doesn't appear to have anything in it but I think the prototype has the references to the forms from boot.janet.
Saikyun
@Saikyun
ah okay. makes sense. maybe I should try that
it would be nice to not have to do method calls :) ideally when building / not repling, everything would just act as regular function calls
Michael Camilleri
@pyrmont

Yeah, just tested and if you do this in a REPL

(fiber/getenv (fiber/current))

all you get is

@{_ @{:value <cycle 0>}}

But if you do this

(table/getproto (fiber/getenv (fiber/current)))

you get

@{os/clock @{:value <cfunction os/clock> :doc "(os/clock)\n\nReturn the number of seconds since some fixed point in time. The clock is guaranteed to be non decreasing in real time."} net/write @{:value <cfunction net/write> :doc "(net/write stream data &opt timeout)\n\nWrite data to a stream, suspending the current fiber until the write completes. Takes an optional timeout in seconds, after which will return nil. Returns nil, or raises an error if the write failed."} bytes? @{:source-map ("boot.janet" 100 1) :value <function bytes?> :doc "(bytes? x)\n\nCheck if x is a string, symbol, keyword, or buffer."} ...}
Michael Camilleri
@pyrmont
Looking at your example code again, I realise that my problem is slightly different. Yours looks to me like a variation of the 'reloading namespaces' kind of problem (do you have to do it?). I think what I'm thinking about is that if you're in one file in an editor that uses the netrepl and you send the content from that buffer to the netrepl server it's evaluated in the current environment. If you then send the content from a different buffer to the netrepl server, it's not evaluated in a different environment (at least it isn't at the moment).
Clojure REPLs (and possibly others) get around this problem by having the REPL environment be always in a particular namespace and allowing the user to manually change the namespace. But Janet's REPL doesn't really work like that. There is sort of just the REPL environment and everything you type in it goes into that environment.
pp
@damnpepe:matrix.org
[m]
Maybe I got it all wrong, but why not just (put modules/cache "my-lib" nil) @Saikyun ?
Michael Camilleri
@pyrmont
@damnpepe: Is that where an imported module is stored so it can be referred to by other modules?
pp
@damnpepe:matrix.org
[m]
yep, I am doing it in my webserver to refresh the templates
but again I can be totally not understanding at all :-)
Saikyun
@Saikyun
@pp I'd have to try it :) I don't know how modules/cache works. one main issue is that when using import normally, all names are thrown away, and iiuc even when using import :fresh, you have to also re-evaluate the defn-calls using the functions you depend on
if I had to wager a guess, the modules/cache-part will solve a similar problem as import :fresh true, but I wonder if it will solve the "thrown away names" problem
I'll try it later and get back to you :)
thanks for the info
pp
@damnpepe:matrix.org
[m]
oh I am going to speculate (import :fresh true) is doing that module/cache thing :-)
so no help probably
Saikyun
@Saikyun
still, good to know about modules/cache, I had no idea :)
so thanks again
pp
@damnpepe:matrix.org
[m]
you are welcome! yumaikas- brought it to my attention not that long ago (just in time I needed them)
Saikyun
@Saikyun
@pyrmont as you say, those are two different problems :) for me, it's all about being able to reload "namespaces". in my case, I have a render loop in main.janet, and it depends on various files. in those files I want to make changes and have them come through to the render loop. wrt: evaluating in different environments -- an environment and/or fiber per netrepl connection might make sense? :) not sure what problem you want to solve
Michael Camilleri
@pyrmont
@damnpepe: Perhaps you might know the answer to this question. If you have a stream created by net/connect, is there a way to check whether there's anything to read in the stream?
pp
@damnpepe:matrix.org
[m]
to read it is only way I know of
Michael Camilleri
@pyrmont
And that consumes it, right?
pp
@damnpepe:matrix.org
[m]
it does yes
Michael Camilleri
@pyrmont
Hmmm.
pp
@damnpepe:matrix.org
[m]
but I do not see scenario, where it could be problem
can you please share yours (as you seem disapointed 😀
Michael Camilleri
@pyrmont
I'm trying to test various things with a stream to a netrepl connection from an ordinary REPL. I have two functions, recv and send which read from and write to the stream respectively. The problem is that if I read from the stream when there's nothing there, it will block.
pp
@damnpepe:matrix.org
[m]
yes, but with the ev it is not that big problem?
in my mental model I tied ev and net as tight as my old mind allowes
Michael Camilleri
@pyrmont
Well, I'm in the REPL and I don't see anyway to cancel the blocking. I guess I could tweak the recv function to have a timeout.
pp
@damnpepe:matrix.org
[m]
that is other way around indeed
Michael Camilleri
@pyrmont
The problem is that I'm using spork/msg to create the receiver (and the sender) and the make-recv and make-send functions don't have the capacity to do timeouts.
I guess those functions aren't exceptionally complicated so I could just tweak them.
pp
@damnpepe:matrix.org
[m]
yep
Saikyun
@Saikyun
@pyrmont do you have a specific example for repling / blocking problem?
don't know if it will help you, but this is how I manage to get netrepl + loop to work together: https://github.com/Saikyun/text-experiment/blob/main/src/main.janet#L217-L235
the ev/sleep call makes it so that the netrepl gets a chance to do its thing :)
when thinking about it, a generator might have been cleaner, haha. anyway :)
Michael Camilleri
@pyrmont
I've got it working now :)
I'm running the netrepl server in a separate process so it's OK for recv to block, just not indefinitely :)
Saikyun
@Saikyun
ah right, in my case I couldn't run netrepl in a separate process / thread, due to having to run raylib calls on main thread
Michael Camilleri
@pyrmont
Ah. Yeah, I'm just trying to play around with some of the stuff that I helped add to run-context and spork/netrepl.
I was trying to get Conjure to work with it but I am not having much luck and am trying to see if something's broken in the implementation (I don't think it is but wanted to double check).
pp
@damnpepe:matrix.org
[m]
lol
dogfooding
Michael Camilleri
@pyrmont
Well, sort of :)