Project

General

Profile

Bug #321

interpreter proposes no near misses for "bin"

Added by John Abbott about 11 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Parser/Interpreter
Target version:
Start date:
25 Feb 2013
Due date:
% Done:

100%

Estimated time:
4.10 h
Spent time:

Description

In C5, if you slightly mistype a name, the interpreter offers a choice of similar names.

But if I type bin() then the suggestions are Min and min; even though Bin exists it is not offered!

Why?


Related issues

Related to CoCoA-5 - Bug #104: Misprints suggestions: Z --> ZZClosed2012-03-15

History

#1 Updated by John Abbott about 11 years ago

  • Subject changed from interpreter proposes no near misses for "Ord" to interpreter proposes no near misses for "bin"

#2 Updated by John Abbott about 11 years ago

  • Category set to Parser/Interpreter
  • Status changed from New to In Progress
  • Target version set to CoCoA-5.0.9

The problem is caused by the fact the suggestions offered depend on the arity in the context in which the name appears.

Since Bin has fixed arity (=2), but the arity was 0 in the input, the interpreter does not propose it. Min and min have variable arity, so they are offered.

If bin is input as a variable then all suggestions appear because any name can be used in that context.

What to do? Arity filtering seems like a good idea, but in this case it produces quite a misleading result.

Here are two possible courses of action:
  1. we could disable arity filtering (might produce lots of useless suggestions?)
  2. we could tell the interpreter to offer two sets of suggestions: those with suitable arity; and any others that match.

#3 Updated by Anna Maria Bigatti over 10 years ago

  • Target version changed from CoCoA-5.0.9 to CoCoA-5.1.0 Easter14

#4 Updated by John Abbott about 10 years ago

  • Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.1.1 Seoul14

#5 Updated by John Abbott over 9 years ago

  • % Done changed from 0 to 10

Now we get slightly different output:

>>> bin();
--> ERROR: Cannot find a variable named "bin" in scope.
Similarly named variables (that you might need to import) are: "Gin", "Min", "min" 
--> bin();
--> ^^^

>>> bin;
--> ERROR: Cannot find a variable named "bin" in scope.
Similarly named variables (that you might need to import) are: "Bin", "Gin", "Min", "gin", "min" 
--> bin;
--> ^^^

Notice that Gin appears in both lists of suggestions, while gin appears in only the second list. This is because of how Gin is defined in BackwardCompatible.cpkg5.

#6 Updated by John Abbott over 9 years ago

  • Target version changed from CoCoA-5.1.1 Seoul14 to CoCoA-5.?.?

#7 Updated by John Abbott over 9 years ago

The place to intervene appears to be Interpreter.C:2775 in the function collectSimilarlyNamedIdentifiers. The procedure returns its result in a single list, so to obtain two lists it will be necessary to change the signature of the procedure.

#8 Updated by John Abbott over 9 years ago

  • Assignee set to John Abbott
I propose the following variation on current behaviour:
  • the suggested names should be in order of increasing levenshtein distance
  • if the name appears as a fn name in a call then name with "inappropriate" arity should appear but only after those with appropriate arity

This means that the set of suggested names does not vary with context, but the order in which they appear may vary (hopefully the "better matches" being earlier in the list).

What do you think? It should not be too hard to implement :-)
NOTE (20140903) damn, it won't be as easy as I'd hoped because Giovanni used std::set rather than list/vector.

#9 Updated by Anna Maria Bigatti over 9 years ago

John Abbott wrote:

I propose the following variation on current behaviour:
  • the suggested names should be in order of increasing levenshtein distance
  • if the name appears as a fn name in a call then name with "inappropriate" arity should appear but only after those with appropriate arity

yes! I like that!

#10 Updated by John Abbott over 9 years ago

  • % Done changed from 10 to 40
I now have a first impl.
  • changed the use of std::set into set::vector
  • implemented the idea of printing the names in increasing order of "remoteness"

I note that there are two distinct fns called collectSimilarlyNamedIdentifiers; I have changed only one of them. The other one appears to be recursive... not sure when it is called.

I'll talk with Anna; if she approves, I'll check in.

#11 Updated by John Abbott over 9 years ago

  • Status changed from In Progress to Closed
  • Target version changed from CoCoA-5.?.? to CoCoA-5.1.1 Seoul14
  • % Done changed from 40 to 100
  • Estimated time set to 4.10 h

After some testing Anna and John approve the idea in comment 8 (already implemented).

We have also increased the max distance allowed when comparing names to (len+3)/4 where len is the length of the name typed by the user.

Also available in: Atom PDF