Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-11

New refactoring idea: extract constant

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Klenin

I think it would be useful to add 'extract constant' refactoring, vaguely similar to 'extract procedure':

procedure P;
begin
  x := y + 17;
end;
=>
procedure P;
const
  LocalConst = 17;
begin
  x := y + LocalConst;
end;

Refactoring dialog should request the name of the constant, and, optionally:
1) Whether to replace all other instances of the literal with the same constant name
2) Whether to put the constant at the procedure or unit level.

Alexander S. Klenin

Reply by email

Graeme Geldenhuys
to Alexander Klenin

2009/11/4 Alexander Klenin :

Show quoted text 6 lines
Refactoring dialog should request the name of the constant, and, optionally: 1) Whether to replace all other instances of the literal with the same constant name 2) Whether to put the constant at the procedure or unit level.

Very nice idea and would be very handy! But I would add one more option - do you want the constant local to the procedure, or unit wide (implementation section const) or global (interface section const)?

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Alexander Klenin
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
2009/11/4 Alexander Klenin : > 2) Whether to put the constant at the procedure or unit level. Very nice idea and would be very handy! But I would add one more option - do you want the constant local to the procedure, or unit wide (implementation section const) or global (interface section const)?

This is what I meant by point (2) above -- probably did not say it precisely enough.
So, should I create a Mantis ticket?

Alexander S. Klenin

Reply by email

Mattias Gaertner
to Alexander Klenin
Show quoted text 14 lines
On Wed, Nov 4, 2009 at 17:15, Graeme Geldenhuys wrote: > 2009/11/4 Alexander Klenin : >> 2) Whether to put the constant at the procedure or unit level. > > > Very nice idea and would be very handy! But I would add one more > option - do you want the constant local to the procedure, or unit > wide (implementation section const) or global (interface section > const)? This is what I meant by point (2) above -- probably did not say it precisely enough. So, should I create a Mantis ticket?

ok

Mattias

Reply by email