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

Handling of exclamation points in Alda REPL #125

Closed
daveyarwood opened this issue Oct 8, 2015 · 6 comments
Closed

Handling of exclamation points in Alda REPL #125

daveyarwood opened this issue Oct 8, 2015 · 6 comments
Labels

Comments

@daveyarwood
Copy link
Member

I just noticed some weird behavior around exclamation points in the REPL:

$ alda repl

 █████╗ ██╗     ██████╗  █████╗
██╔══██╗██║     ██╔══██╗██╔══██╗
███████║██║     ██║  ██║███████║
██╔══██║██║     ██║  ██║██╔══██║
██║  ██║███████╗██████╔╝██║  ██║
╚═╝  ╚═╝╚══════╝╚═════╝ ╚═╝  ╚═╝

            v0.12.0
         repl session

Loading MIDI synth... done.

> (println "hey")
hey
> (println "hey!")
[ERROR] Could not expand event
java.lang.IllegalArgumentException: !"): event not found
        at jline.console.ConsoleReader.expandEvents(ConsoleReader.java:779)
        at jline.console.ConsoleReader.finishBuffer(ConsoleReader.java:631)
        at jline.console.ConsoleReader.accept(ConsoleReader.java:2019)
        at jline.console.ConsoleReader.readLine(ConsoleReader.java:2666)
        at jline.console.ConsoleReader.readLine(ConsoleReader.java:2269)
        at jline.console.ConsoleReader.readLine(ConsoleReader.java:2257)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
        at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:313)
        at alda.repl$start_repl_BANG_.invoke(repl.clj:47)
        at boot.user$eval9827.invoke(boot.user74118737049437660.clj:84)
        at clojure.lang.Compiler.eval(Compiler.java:6782)
        at clojure.lang.Compiler.eval(Compiler.java:6772)
        at clojure.lang.Compiler.eval(Compiler.java:6745)
        at clojure.core$eval.invoke(core.clj:3081)
        at alda.cli$eval9544$fn__9545.doInvoke(cli.clj:81)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at alda.cli$delegate.invoke(cli.clj:116)
        at alda.cli$_main.doInvoke(cli.clj:131)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:379)
        at clojure.lang.AFn.applyToHelper(AFn.java:154)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.core$apply.invoke(core.clj:630)
        at boot.user$_main.doInvoke(boot.user74118737049437660.clj:21)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:379)
        at boot.user$eval9621.invoke(boot.user74118737049437660.clj:25)
        at clojure.lang.Compiler.eval(Compiler.java:6782)
        at clojure.lang.Compiler.load(Compiler.java:7227)
        at clojure.lang.Compiler.loadFile(Compiler.java:7165)
        at clojure.lang.RT$3.invoke(RT.java:319)
        at boot.main$_main$fn__1120.invoke(main.clj:161)
        at boot.main$_main.invoke(main.clj:161)
        at clojure.lang.Var.invoke(Var.java:394)
        at org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke(ClojureRuntimeShimImpl.java:138)
        at org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke(ClojureRuntimeShimImpl.java:129)
        at boot.App.runBoot(App.java:242)
        at boot.App.main(App.java:356)

> (println "hey\!")
(println "hey!")
hey!
> (println \!)
(println !)
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: ! in this context, compiling:(/var/folders/h0/jb2j4f310zx08ynwfxw8lxg00000gn/T/boot.user74118737049437660.clj:84:10)
             java.lang.RuntimeException: Unable to resolve symbol: ! in this context
                         clojure.lang.Util.runtimeException                       Util.java:  221
                            clojure.lang.Compiler.resolveIn                   Compiler.java: 7019
                              clojure.lang.Compiler.resolve                   Compiler.java: 6963
                        clojure.lang.Compiler.analyzeSymbol                   Compiler.java: 6924
                              clojure.lang.Compiler.analyze                   Compiler.java: 6506
                              clojure.lang.Compiler.analyze                   Compiler.java: 6485
                     clojure.lang.Compiler$InvokeExpr.parse                   Compiler.java: 3791
                           clojure.lang.Compiler.analyzeSeq                   Compiler.java: 6725
                              clojure.lang.Compiler.analyze                   Compiler.java: 6524
                              clojure.lang.Compiler.analyze                   Compiler.java: 6485
                clojure.lang.Compiler$BodyExpr$Parser.parse                   Compiler.java: 5861
                       clojure.lang.Compiler$FnMethod.parse                   Compiler.java: 5296
                         clojure.lang.Compiler$FnExpr.parse                   Compiler.java: 3925
                           clojure.lang.Compiler.analyzeSeq                   Compiler.java: 6721
                              clojure.lang.Compiler.analyze                   Compiler.java: 6524
                                 clojure.lang.Compiler.eval                   Compiler.java: 6779
                                 clojure.lang.Compiler.eval                   Compiler.java: 6772
                                 clojure.lang.Compiler.eval                   Compiler.java: 6745
                                          clojure.core/eval                        core.clj: 3081
                                  alda.repl.core/interpret!                        core.clj:   49
                                   alda.repl/start-repl!/fn                        repl.clj:   63
                                      alda.repl/start-repl!                        repl.clj:   48
                                         boot.user/eval9827  boot.user74118737049437660.clj:   84
                                 clojure.lang.Compiler.eval                   Compiler.java: 6782
                                 clojure.lang.Compiler.eval                   Compiler.java: 6772
                                 clojure.lang.Compiler.eval                   Compiler.java: 6745
                                          clojure.core/eval                        core.clj: 3081
                                       alda.cli/eval9544/fn                         cli.clj:   81
                                clojure.lang.RestFn.applyTo                     RestFn.java:  137
                          clojure.lang.AFunction$1.doInvoke                  AFunction.java:   29
                                 clojure.lang.RestFn.invoke                     RestFn.java:  408
                                          alda.cli/delegate                         cli.clj:  116
                                             alda.cli/-main                         cli.clj:  131
                                 clojure.lang.RestFn.invoke                     RestFn.java:  408
                                    clojure.lang.Var.invoke                        Var.java:  379
                             clojure.lang.AFn.applyToHelper                        AFn.java:  154
                                   clojure.lang.Var.applyTo                        Var.java:  700
                                         clojure.core/apply                        core.clj:  630
                                            boot.user/-main  boot.user74118737049437660.clj:   21
                                 clojure.lang.RestFn.invoke                     RestFn.java:  408
                                    clojure.lang.Var.invoke                        Var.java:  379
                                         boot.user/eval9621  boot.user74118737049437660.clj:   25
                                 clojure.lang.Compiler.eval                   Compiler.java: 6782
                                 clojure.lang.Compiler.load                   Compiler.java: 7227
                             clojure.lang.Compiler.loadFile                   Compiler.java: 7165
                                   clojure.lang.RT$3.invoke                         RT.java:  319
                                         boot.main/-main/fn                        main.clj:  161
                                            boot.main/-main                        main.clj:  161
                                    clojure.lang.Var.invoke                        Var.java:  394
org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke     ClojureRuntimeShimImpl.java:  138
org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke     ClojureRuntimeShimImpl.java:  129
                                           boot.App.runBoot                        App.java:  242
                                              boot.App.main                        App.java:  356
> (println \\!)
(println \!)
!

Apparently the JLine ConsoleReader does something special with !, something about expanding an event?

Strangely, this bug doesn't seem to apply to things like (tempo! 200) (which still work as expected). I'm not sure under what circumstances it tries to "expand" the !, but maybe it doesn't apply to ! appearing at the end of a word. Just a shot in the dark at a possible explanation.

Possible fixes:

  • learn more about JLine ConsoleReader, see if there is a way we can turn this behavior off
  • (less ideal) manually escape !, maybe just inside of strings and character literals?
@daveyarwood daveyarwood added the bug label Oct 8, 2015
@daveyarwood
Copy link
Member Author

Aha: it looks like you can turn off this "event-expanding" behavior: jline/jline2#96

@refi64
Copy link

refi64 commented Oct 8, 2015

Side note: try doing echo A! in bash.

@daveyarwood
Copy link
Member Author

@kirbyfan64

bash-3.2$ echo A!
A!

@daveyarwood
Copy link
Member Author

Fix incoming 👍

@refi64
Copy link

refi64 commented Oct 9, 2015

@daveyarwood Meant echo !A or echo !1.

@daveyarwood
Copy link
Member Author

@kirbyfan64 Oh yeah -- interesting. I guess ConsoleReader emulates that behavior from bash, by default.

daveyarwood added a commit to alda-lang/alda-client-java that referenced this issue Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants