Build "Did you mean?"

98 views
Skip to first unread message

Pankaj Doharey

unread,
Sep 12, 2018, 4:42:38 AM9/12/18
to Clojure Dev
I am a former rubyist, and in ruby there is this feature called "Did you mean?"

For instance :

irb(main):001:0> s = 'helloworld'.spli(//)
Traceback (most recent call last):
2: from /Users/xxxx/.rbenv/versions/2.6.0-dev/bin/irb:11:in `<main>'
1: from (irb):1
NoMethodError (undefined method `spli' for "helloworld":String)
Did you mean? split
irb(main):002:0> s = 'helloworld'.split(//)
=> ["h", "e", "l", "l", "o", "w", "o", "r", "l", "d"]


Something similar in clojure would be :

user=> (str/split "helloworld" #"")
CompilerException java.lang.RuntimeException: No such var: clojure.string/spli, c ...
Did you mean? (str/split ...

Usually the Did you mean would be in some error color, I think this could be a nice feature for beginners to have method suggestions. and aesthetically just nice.

Do you think it could be a worthy addition to the clojure ecosystem ? It isnt a very difficult suggestion to implement only one file would be touched Compiler.java and tests files. Doesnt require many changes if we consider we moving with this.

Message has been deleted

Andy Fingerhut

unread,
Sep 12, 2018, 11:21:29 AM9/12/18
to cloju...@googlegroups.com
I cannot speak for the Clojure core developers, but I would guess that they might point out that the Clojure run time most likely provides all of the information needed to generate such a suggestion (e.g. see the definition of the "apropos" function), and to hook into examining the causes of exceptions in a REPL.  For example, see the talk "REPL-Driven Development" by Stuart Halloway.  A transcript and link to video recording is here: https://github.com/matthiasn/talk-transcripts/blob/master/Halloway_Stuart/REPLDrivenDevelopment.md

Andy

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.

Alex Miller

unread,
Sep 12, 2018, 11:29:16 AM9/12/18
to cloju...@googlegroups.com
Yeah, I don't think this needs to be in core. I suspect this is probably mostly covered by existing libs already, like clojure-complete (https://github.com/ninjudd/clojure-complete). 

On Wed, Sep 12, 2018 at 10:21 AM, Andy Fingerhut <andy.fi...@gmail.com> wrote:
I cannot speak for the Clojure core developers, but I would guess that they might point out that the Clojure run time most likely provides all of the information needed to generate such a suggestion (e.g. see the definition of the "apropos" function), and to hook into examining the causes of exceptions in a REPL.  For example, see the talk "REPL-Driven Development" by Stuart Halloway.  A transcript and link to video recording is here: https://github.com/matthiasn/talk-transcripts/blob/master/Halloway_Stuart/REPLDrivenDevelopment.md

Andy
On Wed, Sep 12, 2018 at 1:42 AM Pankaj Doharey <pankaj...@gmail.com> wrote:
I am a former rubyist, and in ruby there is this feature called "Did you mean?"

For instance :

irb(main):001:0> s = 'helloworld'.spli(//)
Traceback (most recent call last):
        2: from /Users/xxxx/.rbenv/versions/2.6.0-dev/bin/irb:11:in `<main>'
        1: from (irb):1
NoMethodError (undefined method `spli' for "helloworld":String)
Did you mean?  split
irb(main):002:0> s = 'helloworld'.split(//)
=> ["h", "e", "l", "l", "o", "w", "o", "r", "l", "d"]


Something similar in clojure would be :

user=> (str/split "helloworld" #"")
CompilerException java.lang.RuntimeException: No such var: clojure.string/spli, c ...
Did you mean? (str/split ...

Usually the Did you mean would be in some error color, I think this could be a nice feature for beginners to have method suggestions. and aesthetically just nice.

Do you think it could be a worthy addition to the clojure ecosystem ? It isnt a very difficult suggestion to implement only one file would be touched Compiler.java and tests files. Doesnt require many changes if we consider we moving with this.

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev+unsubscribe@googlegroups.com.

To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev+unsubscribe@googlegroups.com.

Pankaj Doharey

unread,
Sep 12, 2018, 11:34:13 AM9/12/18
to cloju...@googlegroups.com
i wasn’t aware of this. thanks!
On Wed, 12 Sep 2018 at 8:59 PM, Alex Miller <al...@puredanger.com> wrote:
Yeah, I don't think this needs to be in core. I suspect this is probably mostly covered by existing libs already, like clojure-complete (https://github.com/ninjudd/clojure-complete). 
On Wed, Sep 12, 2018 at 10:21 AM, Andy Fingerhut <andy.fi...@gmail.com> wrote:
I cannot speak for the Clojure core developers, but I would guess that they might point out that the Clojure run time most likely provides all of the information needed to generate such a suggestion (e.g. see the definition of the "apropos" function), and to hook into examining the causes of exceptions in a REPL.  For example, see the talk "REPL-Driven Development" by Stuart Halloway.  A transcript and link to video recording is here: https://github.com/matthiasn/talk-transcripts/blob/master/Halloway_Stuart/REPLDrivenDevelopment.md

Andy
On Wed, Sep 12, 2018 at 1:42 AM Pankaj Doharey <pankaj...@gmail.com> wrote:
I am a former rubyist, and in ruby there is this feature called "Did you mean?"

For instance :

irb(main):001:0> s = 'helloworld'.spli(//)
Traceback (most recent call last):
        2: from /Users/xxxx/.rbenv/versions/2.6.0-dev/bin/irb:11:in `<main>'
        1: from (irb):1
NoMethodError (undefined method `spli' for "helloworld":String)
Did you mean?  split
irb(main):002:0> s = 'helloworld'.split(//)
=> ["h", "e", "l", "l", "o", "w", "o", "r", "l", "d"]


Something similar in clojure would be :

user=> (str/split "helloworld" #"")
CompilerException java.lang.RuntimeException: No such var: clojure.string/spli, c ...
Did you mean? (str/split ...

Usually the Did you mean would be in some error color, I think this could be a nice feature for beginners to have method suggestions. and aesthetically just nice.

Do you think it could be a worthy addition to the clojure ecosystem ? It isnt a very difficult suggestion to implement only one file would be touched Compiler.java and tests files. Doesnt require many changes if we consider we moving with this.

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.

To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.

To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages