[Pas2js] Built-in helper methods for Double type

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Sep 11 22:11:43 CEST 2019


On Wed, 11 Sep 2019 21:22:43 +0200
Sven Barth via Pas2js <pas2js at lists.freepascal.org> wrote:

>[...]
> > Iff there would be a modifier or attribute to define a read only
> > type helper method, the compiler could create shorter code.  
> 
> Considering that Delphi is using attributes for most such things as
> well (WeakRef, Volatile, etc.) you could add a magic
> "SelfIsConstAttribute" or something like that...

Yes. Probably something shorter like [ConstSelf].

 
>[...]
> Couldn't external [methods] be considered as "const" anyway? Or
> can JS code modify "this"?

AFAIK JS cannot modify the outer "this".
External methods of a helper for base types (e.g. double) is not yet
implemented. It would probably work the same as for external classes,
that is "value.toString" is converted to "value.toString()".


Mattias


More information about the Pas2js mailing list