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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broaden allowed syntax for DSL #31

Merged
merged 3 commits into from
Sep 24, 2015
Merged

Broaden allowed syntax for DSL #31

merged 3 commits into from
Sep 24, 2015

Conversation

emiln
Copy link
Owner

@emiln emiln commented Sep 23, 2015

Until now a command must start with a keyword. This has been relaxed and a command can now start with a keyword, a symbol, or a string.

This means that all of the following are legal ways to represent a
click:

[click] [:click] ["click"] (click) (:click) ("click")

This closes #30.

Until now a command must start with a keyword. This has been relaxed
and a command can now start with a keyword, a symbol, or a string.

This means that all of the following are legal ways to represent a
click:

[click] [:click] ["click"] (click) (:click) ("click")
@emiln
Copy link
Owner Author

emiln commented Sep 23, 2015

Since rudimentary error handling is being introduced anyway, it'd be nice to print a list of legal commands if an illegal one is encountered. All of these can be formatted into a nice string like so:

(->> process-event
  (.getMethodTable)
  (map first)
  (remove (partial = :default))
  (sort)
  (clojure.string/join ", "))

#30

Using a wrong command name will now produce an error message
including the names of all currently implemented commands. This is
fetched dynamically by inspecting the MultiFn and should always be
up to date.
(defmethod process-event :click
(comp name first))

(defn valid-commands
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really an IO-related function, and it should really have a docstring.

#30

The function to look up functions contained in a multimethod has been
moved to a utils namespace and now sports a proper docstring.
emiln added a commit that referenced this pull request Sep 24, 2015
Broaden allowed syntax for DSL
@emiln emiln merged commit 38e2ec1 into master Sep 24, 2015
@emiln emiln deleted the broaden-syntax branch October 18, 2015 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symbols instead of keywords?
1 participant