[Pas2js] Prefix_&_support
warleyalex
warleyalex at yahoo.com.br
Mon May 14 17:11:03 CEST 2018
Let's say in your application, move your cursor beyond the . (period
character)
after the TJSUint8Array statement, and press Ctrl+Space. The Code Completion
window appears.
Locate the "of" method. Uh... there's an ugly "_of" undercore method, hit
ENTER your code will
be completed to:
-------------------------
var
compressed_UInt8Array: TJSUint8Array;
begin
compressed_UInt8Array := TJSUint8Array._of(1,2,3);
---------------------------
Now, try putting the "&" prefix rather than "_" prefix to all indentifiers
declared in the JS.pas unit,
e.g.
TJSUint8Array = class external name 'Uint8Array' (TJSTypedArray)
private
{...}
public
{...}
class function &of(aValue : jsValue) : TJSUInt8Array; varargs;external
name 'of';
end;
TJSPromise = class external name 'Promise'
{...}
function &then (onAccepted : TJSPromiseResolver) : TJSPromise; external
name 'then';
function catch (onRejected : TJSPromiseResolver) : TJSPromise;
function &finally(value : TJSPromiseFinallyHandler): TJSPromise;
end;
The consequence is that you should see the "correct identifier" when the
code completion
apperars, when you hit ENTER, you've got the code completed with the ugly
"&of" method.
Pas2JS compiler, could do some black magic, at compile-time evaluations, to
support for
the ‘&’ escape prefix to allow using reserved words as identifiers.
I think it's a good practice to prefix all Pascal identifies with an &
prefix,
usually declared in external classes, so the pas2js compiler can correctly
compile the code,
it won't get name conflict, just because have already evaluated the
identifier, for instance in:
compressed_UInt8Array := TJSUint8Array.of(1,2,3);
or
defer
.then(@_doTask1)
.then(@_doTask2)
.then(@_doTask3);
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list