sharkdp / numbat

A statically typed programming language for scientific computations with first class support for physical dimensions and units
https://numbat.dev
Apache License 2.0
1.26k stars 53 forks source link

Allow .nbt files to be loaded in REPL environment #573

Open NogginBops opened 1 month ago

NogginBops commented 1 month ago

It's very handy for testing and development to be able to load functions specified in a file into an interactive session.

This might be possible using modules (?), but the documentation around modules is very lacking and it's very unclear how you would load a file in the REPL environment.

sharkdp commented 1 month ago

Did you see this part of the documentation? If not, where did you look? What did you search for?

https://numbat.dev/doc/cli-customization.html#custom-functions-constants-units

NogginBops commented 1 month ago

I don't want to have the file be in some modules folder. I want to be able to load any file anywhere on my computer. Like loading files in prolog repl or similar.

Goju-Ryu commented 1 month ago

I could see utility in a command that loads the contents of a file not necessarily in a modules folder. It would make it easier to use the cli as a REPL while developing a script, without cluttering the namespace with each new project or having to update configurations or environment variables for each.
When writing F# code, I frequently do something similar by loading scripts into fsi to experiment with the outputs of the functions I wrote. Currently I often do the same in Numbat by copy and pasting definitions manually.

sharkdp commented 1 month ago

Okay. So basically the counterpart to the save command. Sounds reasonable.

Bzero commented 1 month ago

I started working on this feature but was not sure how to call the new command. Maybe load as the opposite of save or just run possibly?

sharkdp commented 3 weeks ago

I started working on this feature but was not sure how to call the new command. Maybe load as the opposite of save or just run possibly?

I like load. Maybe hold off from doing too much work on commands until this discussion is resolved. Also note that there is another commands-PR (#590)