Forum > FPC development

Feature request: nested procedure referrable as procedure of object

<< < (2/2)

Jonas Maebe:
Delphi does not support "is nested", so it's not enabled by default in {$mode delphi}. As the manual states: "This requires that the sources be compiled in macpas or ISO mode, or that the nestedprocvars modeswitch be activated". The example in the manual also shows how to activate that modeswitch.

It needs to be different because the calling convention for nested routines is completely different from methods. The only way to do all of that transparently behind the scenes would be by turning procvars into reference-counted heap-allocated entities, which would slow them down significantly and which would probably break tons of existing hackish code (you may not care about either of those things, but you're not the one having to deal with the resulting bug reports and complaints either). Pascal is not Lisp.

deanon:
This statement sounds like tombstone which significantly constraints the further language evolution and usability.
But, again, isn't it possible at least to make 'is nested' and 'of object' compatible?
Why not to generate internal stubs this way ?


--- Code: ---
type nestedproc = procedure is nested;
type objectproc = procedure of object;

type stub = object np: nestedproc; procedure proc(); end;
procedure stub.proc(); begin np() end;

procedure call( op: objectproc ); begin...end;

procedure blah();
var s: stub;
procedure nested(); begin ... end;
begin
  s.np := @nested;
  call( @s.proc );
end;



--- End code ---

Jonas Maebe:

--- Quote from: deanon on August 01, 2015, 06:09:43 pm ---This statement sounds like tombstone which significantly constraints the further language evolution and usability.

--- End quote ---
So does breaking backward compatibility every other full moon because the language maintainers decided that it hamstrung them. Constantly breaking code that currently works is much more of a tombstone, because nobody wants to rewrite their code all the time (then they can just as well start using a different language). In fact, if you want to fix everything in a language, you have to design a language from scratch.


--- Quote ---But, again, isn't it possible at least to make 'is nested' and 'of object' compatible?
Why not to generate internal stubs this way ?

--- End quote ---
It would result in a lot of code bloat.

Navigation

[0] Message Index

[*] Previous page

Go to full version