Rainer Stratmann wrote:
Am Thursday 30 August 2012 18:07:13 schrieb Jonas Maebe:
On 30 Aug 2012, at 17:14, Rainer Stratmann wrote:
TP for DOS at
least supports a function result (as I remember) thus it is not Delphi
only as you mention.
Turbo Pascal does not support the "result" alias for the function result.

What's wrong with such a message that is easy to implement and will help
beginners to freepascal a lot?
We give such a message when someone tries to define a "class" type without
having ObjFPC/Delphi mode activated. That is a message that is always
correct, because

type
  tsomething = class
  end;

does not and cannot have any other meaning in another compilation mode. As
has been pointed out by other people, that is not true for random
occurrences of the word "result" in the source code.

Even then the message
"are you in the right syntax-mode? only ObjFPC (-MObjfpc) or Delphi (-Mdelphi) mode supports a function result" can not be wrong. Added to this that the occurence of the identifier "result" not using in combination with a function result is very unlikely. I think 99,99% has to do with the scenario that I described. And maximum in one of a thousand cases it is the scenario that has been pointed out above.

But such an error message would have to come from code that recognised 'result' as a special case, which it is not: in no mode is 'result' either a predefined identifier or a reserved word. Or rather (speculating, and expecting Jonas to correct me :-) 'result' has a special meaning when a function declaration is parsed, but not when the block which forms the function body is compiled.

I'm not denying that an improved error message might be useful. However its implementation might result in far more work than is justified.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to