-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Have code run conditionally on load() vs. command line #572
Comments
Could we just have a global variable that is set by the REPL to indicate whether it's the REPL or not? |
The Python and Ruby approaches are variations on that (with |
One way to tell is if |
That's the Ruby approach, but unless we provide a special variable which returns the name of the file you are in (or if that already exists, in which case this just becomes documentation) you have to hardcode the file name. That would be sufficient to make this not painful. |
Actually, that's a bug. I'm not an expert on the Python thing, but isn't this generally considered to be a misfeature that's just been rampantly abused? I've never really wanted this in Perl or Ruby — a script is a script, a module is a module. |
And interactive debugging from the REPL or a test harness requires that you be able to do both. Let's say I have a script foo.jl with a |
Doesn't that seem to indicate that you should move the definition of |
I have a script. That script has repeated code which I want to make a function out of, but which is still quite specific to that script. I really don't want to put that in a separate file just so I can test that out from the REPL. Also "bigness" is a relative term in technical computing. I've written a lot of throwaway MATLAB that I still need to quickly check before using--forcing me into a heavyweight, multiple-file workflow for that isn't going to make me happy. |
Ok, fair enough. We can add something like this. Not sure what it should look like. Maybe reflective access to the options that |
I can see the case of wanting to load a script in the repl to test its functions without calling |
Sounds good to me. |
8c84b8c (#56431) Stdlib: SparseArrays URL: https://github.com/JuliaSparse/SparseArrays.jl.git Stdlib branch: release-1.10 Julia branch: backports-release-1.10 Old commit: 279b363 New commit: 8c84b8c Julia version: 1.10.6 SparseArrays version: 1.10.0(Does not match) Bump invoked by: @IanButterworth Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaSparse/SparseArrays.jl@279b363...8c84b8c ``` $ git log --oneline 279b363..8c84b8c 8c84b8c Merge pull request #572 from JuliaSparse/backports-release-1.10 ec38631 Update ci.yml with more architectures 46c8f7e Merge branch 'release-1.10' into backports-release-1.10 2d762b3 Manual commit for PR #550 to backport to 1.10 (#577) 5c37298 Add versions to include arch b539588 Update CI fa49620 Disable nested dissection d2a80a6 Change default QR tolerance to match SPQR (#557) 9b8cd14 SparseMatrixCSC constructor with a Tuple of Integers (#523) 546be18 Fix docs conflict when building as part of full Julia docs (#430) 30fbfc6 Test suite: activate a temp project if we need to install Aqua.jl during the test suite (#425) 91b0aa5 doc: move solvers doc to `src\solvers.md` (#576) 5d3724a Inline sparse-times-dense in-place multiplication ``` Co-authored-by: Dilum Aluthge <[email protected]>
8c84b8c (#56431) Stdlib: SparseArrays URL: https://github.com/JuliaSparse/SparseArrays.jl.git Stdlib branch: release-1.10 Julia branch: backports-release-1.10 Old commit: 279b363 New commit: 8c84b8c Julia version: 1.10.6 SparseArrays version: 1.10.0(Does not match) Bump invoked by: @IanButterworth Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaSparse/SparseArrays.jl@279b363...8c84b8c ``` $ git log --oneline 279b363..8c84b8c 8c84b8c Merge pull request #572 from JuliaSparse/backports-release-1.10 ec38631 Update ci.yml with more architectures 46c8f7e Merge branch 'release-1.10' into backports-release-1.10 2d762b3 Manual commit for PR #550 to backport to 1.10 (#577) 5c37298 Add versions to include arch b539588 Update CI fa49620 Disable nested dissection d2a80a6 Change default QR tolerance to match SPQR (#557) 9b8cd14 SparseMatrixCSC constructor with a Tuple of Integers (#523) 546be18 Fix docs conflict when building as part of full Julia docs (#430) 30fbfc6 Test suite: activate a temp project if we need to install Aqua.jl during the test suite (#425) 91b0aa5 doc: move solvers doc to `src\solvers.md` (#576) 5d3724a Inline sparse-times-dense in-place multiplication ``` Co-authored-by: Dilum Aluthge <[email protected]>
To make interactive testing of Julia scripts easier and improve the ability to reuse components, it would be nice if there were an equivalent to Python's:
or Ruby's
The text was updated successfully, but these errors were encountered: