Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define __MAIN_NS__ in RunCommand #524

Closed
wants to merge 5 commits into from

Conversation

Chemaclass
Copy link
Member

馃 Background

Issue: #523

馃挕 Goal

To be able to ignore phel code when running tests or compiling code, especially code that involves I/O operations.

馃敄 Changes

  • Introduce a new global magic constant __MAIN_NS__ that will return the value of the main namespace that it's being executed

馃И For example

(ns phel\game)

(if (= __MAIN_NS__ "phel\\game")
  (loop []
    (play-hand)
    (println)
    (recur)))

@Chemaclass Chemaclass added the enhancement New feature or request label Oct 11, 2022
@Chemaclass Chemaclass self-assigned this Oct 11, 2022
@jenshaase
Copy link
Member

Doesn't this do basically do the same as the *compile-mode* flag (maybe this is a bit undocumented):

(when-not compile-mode
(loop []
(play-hand)
(println)
(recur)))

@Chemaclass
Copy link
Member Author

Oh, gosh, of course it's the same"! I forgot about it, but it's exactly doing what I wanted. So I will close this PR as there is no benefit on it for now 馃槃

(when-not *compile-mode*
  (try
    (main)
    (catch RuntimeException e
      (println)
      (println (php/-> e (getMessage))))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants