On Thu, 27 Mar 2014, Mark Morgan Lloyd wrote:

Michael Van Canneyt wrote:
Hi,

Is it possible to have the following in the code tools:

I would like to be able to specify a code snippet that is inserted at the start and end of a procedure (after begin, before end keywords). The code snippet should contains some macros like $(CLASSNAME) $(METHODNAME).
Conceivably, other macros can be thought of: parameters, unit name etc.

The intended use is that the IDE generates stuff like

Procedure TMyClass.MyMethod;

begin
  {$IFDEF LOGPROCESSFLOW}Log('Entering TMyClass.MyMethod');{$ENDIF}

  {$ENDIF LOGPROCESSFLOW}Log('Exiting TMyClass.MyMethod');{$ENDIF}
end;

If the compiler could track the current procedure (or function, or class.method etc.) name, then couldn't that be done with a macro? Then the app source would be a less-obtrusive:

Procedure TMyClass.MyMethod;

begin_logged

end_logged;

I prefer not to use macros. This is not C.
I like to see explicitly what is happening.
Pascal macros are also not customizable/parametrizable (as the IDE macros are).


Otherwise, since this is such a common requirement, how about a non-fatal equivalent of Assert()?

I don't think this should be a promoted to a language feature either.

There may be additional use cases for this feature, which we cannot all cover 
with language features.

The comment header for one is something encountered quite often in teams that 
need to follow some standards,
for ISO 9001 etc.

In the IDE, at the level of generated sources, the user is able to control 
every aspect of what happens.

That may well include inserting any hypothetical pascal-language-level macro.

Michael.

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to