Recent

Author Topic: request/suggestion/improvement in Lazarus or FPC  (Read 455 times)

440bx

  • Hero Member
  • *****
  • Posts: 4648
request/suggestion/improvement in Lazarus or FPC
« on: September 27, 2024, 05:56:46 pm »
Hello,

consider the following code:
Code: Pascal  [Select][+][-]
  1. {$APPTYPE CONSOLE}
  2.  
  3. program _CursorLocation;
  4.  
  5. function TakesParameter(Parameter : integer) : boolean;
  6. begin
  7.   result := FALSE;
  8.  
  9.   result := TRUE;
  10. end;
  11.  
  12.  
  13. var
  14.  LongVariableName : string;
  15.  
  16. begin
  17.   TakesParameter(LongVariableName);
  18.  
  19.   readln;
  20. end.                

the parameter type being passed to the function is incorrect (string instead of integer), this produces the error:
Code: Text  [Select][+][-]
  1. CursorLocation.lpr(17,34) Error: Incompatible type for arg no. 1: Got "AnsiString", expected "LongInt"
which is correct but, note that the location is specified as column 34 which is the end of variable name, i.e, the location of the close parenthesis.  It would be more convenient if the cursor was left at the _beginning_ of the variable name instead of the end.

Ideally, I think it would probably be FPC that should implement the improvement but, if for whatever reason it cannot be done in FPC then it seems possible to implement it in Lazarus.

Comments welcome.

Attached is a screenshot of the situation (caused by the code above.)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

rvk

  • Hero Member
  • *****
  • Posts: 6499
Re: request/suggestion/improvement in Lazarus or FPC
« Reply #1 on: September 27, 2024, 06:01:00 pm »
Is "for arg no. 1" not hint enough  :P

Not sure if the core developers will look at this, but I don't think they are on the forum (at least not many of them).

440bx

  • Hero Member
  • *****
  • Posts: 4648
Re: request/suggestion/improvement in Lazarus or FPC
« Reply #2 on: September 27, 2024, 06:06:04 pm »
Is "for arg no. 1" not hint enough  :P
The message itself is fine.  The "problem" is that you can't start editing the incorrect variable name because the cursor is at the end of the variable instead of at the beginning (which would simplify editing the incorrect name.)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10454
  • Debugger - SynEdit - and more
    • wiki
Re: request/suggestion/improvement in Lazarus or FPC
« Reply #3 on: September 27, 2024, 07:35:51 pm »
Is "for arg no. 1" not hint enough  :P
The message itself is fine.  The "problem" is that you can't start editing the incorrect variable name because the cursor is at the end of the variable instead of at the beginning (which would simplify editing the incorrect name.)

Well that depends...
- If you want to delete the name to replace it: ctrl-backspace (but yes that can be done from either side)
- If you typed "SomeObject" and forgot to add the value like "SomeObject.MyList" then the position is perfect.
- Same if it is a pointer and you forgot the ^ deref.
- And if it is the wrong method you are calling, then any pos is wrong.

Even if you went to the begin of the term, what is the begin?
Code: Pascal  [Select][+][-]
  1.   MyFunc(foo.bar.some.not_a_list)
Do I really just need to replace the last ident? Or maybe several or all?

IMHO it can't be predicted how the user wants to edit the faulty source.

Some users maybe would prefer if the word was selected (if an identifier is marked as the problem, maybe different if it is a symbol). I would probably be annoyed by that (I probably wouldn't mind the at the begin of the word, in this case... but not important to me)

440bx

  • Hero Member
  • *****
  • Posts: 4648
Re: request/suggestion/improvement in Lazarus or FPC
« Reply #4 on: September 27, 2024, 07:56:33 pm »
Well that depends...
- If you want to delete the name to replace it: ctrl-backspace (but yes that can be done from either side)
- If you typed "SomeObject" and forgot to add the value like "SomeObject.MyList" then the position is perfect.
- Same if it is a pointer and you forgot the ^ deref.
- And if it is the wrong method you are calling, then any pos is wrong.
Good points.  I only thought about the mistakes I most commonly make but, other people make other mistakes. The second one is likely important/convenient to OOP programmers. 

After reading your reply, I think it's likely just fine the way it currently is. 
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5726
  • Compiler Developer
Re: request/suggestion/improvement in Lazarus or FPC
« Reply #5 on: September 28, 2024, 04:04:11 pm »
Not sure if the core developers will look at this, but I don't think they are on the forum (at least not many of them).

On the contrary. Most core devs (of FPC) are more or less active here.

 

TinyPortal © 2005-2018