[fpc-devel] Pascal Smart Pointers Idea + ARC implementation

Maciej Izak hnb.code at gmail.com
Mon May 30 22:09:25 CEST 2016


2015-10-10 21:12 GMT+02:00 Sven Barth <pascaldragon at googlemail.com>:

>
> "@@" (though I have to admit that I don't know where you got that @@ from;
> was that introduced in Delphi recently?)).
>
> It's not an easy topic and I'd really welcome the input of other core
> developers...
>

Somehow I forgot to answer...

@@ is old syntax (maybe even from TP?). @@ is used to get pointer to
variable which holds pointer to procedure/function.

=== begin code ===
procedure foo; begin end;

var
  p: procedure;
  pp: pointer;
begin
  Assert(@p = nil);
  Assert(addr(p) = nil);
  pp := @@p;
  Assert(pp <> nil);
  p := @foo;
  Assert(@p = @foo);
  Assert(addr(p) = addr(foo));
  Assert(pp = @@p);
end.
=== end code ===

another way to get pointer to that kind of variable instead of @@ is:

=== begin code ===
function getptr(var x): pointer;
begin
  Result := @x;
end;
var
  p: procedure;
  pp: pointer;
begin
  pp := getptr(p);
=== end code ===
-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160530/04d1b66e/attachment.html>


More information about the fpc-devel mailing list