Re: compiled code & ShowMessage



claude.animo@xxxxxxxxx wrote:
Rob,
thank you for answering my question.

The compiler only works with what it's given, and if you give it a call to a VCL function, then that's what it will generate.

Any compiler is designed in order to optimize the processed code
(size/speed), without altering the semantic/behaviour of the program.

A compiler that recognizes the semantics of a program is a *very* sophisticated compiler. I'm not aware of any such compilers in existence.

When I use ShowMessage, I don't ask for a specific machine code
implementation.

Yes you do. You ask for the specific function ShowMessage, which refers to the function declared and implemented in the Dialogs unit. Since that's the only implementation of ShowMessage available, you have necessarily asked for that.

I just ask for a behaviour.

You asked for the behavior of a program that calls the Dialogs.ShowMessage function. Why would the compiler give you anything other than what you asked for?

Any compiler must be clever enough, to produce the "best"
implementation.

Wrong. It needs to produce a *correct* implementation. How would compiler determine what "best" means? How can it recognize the "best" implementation? How can you or I recognize it?

Actually, compilers don't produce implementations. To have it produce an implementation suggests that the compiler has some leeway -- some creativity in accomplishing what it has been asked to do. But it doesn't. You've provided the source code, and the compiler's job is to turn it into the corresponding machine instructions.

It's your job, as the programmer, to provide an implementation based on the specifications you have. You get to choose how to implement the specifications.

Calling an API is not always a user choice.

Then whose choice is it?

In my case
I don't claim for anything but displaying a message.

And that's exactly what you got.

From a compiler point of view, in this specific case, the targetted OS
only matters.

From the compiler's point of view, it has encountered a command from the programmer to call the Dialogs.ShowMessage function. If it called something else instead, then that would be an error.

That's why I'm so surprised by the overwhelming amount of generated
code.

Claude



--
Rob
.



Relevant Pages

  • Re: GPL vs non-GPL device drivers
    ... shipped the source code of the modified POP server. ... given you the compiler he compiled it with, ... Actually, if memory serves, when you license a work under the GPL, part of the ... a derivative work" the claim is invalid - because, as it has been shown, a ...
    (Linux-Kernel)
  • Re: more compiler switches
    ... Also print the version number of the compiler ... driver program and of the preprocessor and the compiler proper. ... C source code which should not be preprocessed. ... Like -v except the commands are not executed and all command arguments are ...
    (comp.lang.fortran)
  • portable makefiles with f90 modules
    ... What is the current status of designing portable makefiles (on ... unix-like OSs and beyond) in large programming projects with f90 ... I'm assuming in a large project that source code is spread across ... files (or whatever they happen to be called by that compiler). ...
    (comp.lang.fortran)
  • Re: ideas for a BASIC compiler
    ... handle register access. ... the value 42 is saved to register foo. ... makes the compiler more complex. ... share source code between the systems, e.g. a general program for a sigma ...
    (comp.arch.embedded)
  • Re: Understanding Error Messages
    ... The listing you can see my listing in: ... you fix mainframe compile problems by fixing the mainframe source code ... Finally, just like you are using a 15 year old compiler on the PC, you are also ...
    (comp.lang.cobol)