Forum > General

How to make an alias for generic advanced record?

(1/1)

alpine:
Help!
Does anybody know how to create an alias for this one:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---generic TSmartPointer<T: class> = record {...} end;
I want to use it under the name of, say:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---generic TAuto<T: class> = record {...} end;But I can't figure out how to do it...

PascalDragon:
You can't. Simple as that.

Thaddy:
You can with a macro.
{$macro on}{$define Tauto:=TSmartpointer}

This can maybe have side effects, though.

MarkMLl:

--- Quote from: Thaddy on September 15, 2022, 09:41:02 am ---You can with a macro.
{$macro on}{$define Tauto:=TSmartpointer}

This can maybe have side effects, though.

--- End quote ---

Noting PascalDragon's comment of a few days ago that "Macros are only matched on a full token.", i.e. there's no risk of a substring match.

They can be very useful indeed, particularly since (unlike C macros) they can be multi-line. It's unfortunate that they can't take parameters, but TBH I can't think of a single macro-expansion preprocessor that is neither embarrassingly primitive nor impenetrably esoteric.

MarkMLl

alpine:

--- Quote from: PascalDragon on September 15, 2022, 09:28:17 am ---You can't. Simple as that.

--- End quote ---
Thanks! It is good to know there is no way.


--- Quote from: Thaddy on September 15, 2022, 09:41:02 am ---You can with a macro.
{$macro on}{$define Tauto:=TSmartpointer}

This can maybe have side effects, though.

--- End quote ---
It came up into my mind, but there are several source files to include into. I'd better refactor.

Navigation

[0] Message Index

Go to full version