ES6 compatibilty

Issue #118 new
Christian Budde created an issue

I'm currently working with Quill (https://quilljs.com), which the user can easily extend by using ES6. For example adding a custom divider can be as easy as this:

class DividerBlot extends BlockEmbed { }
DividerBlot.blotName = 'divider';
DividerBlot.tagName = 'hr';

However, without using JavaScript asm or rather complex polyfills it's not possible to translate the above code directly to DWScript at the moment. The closest is something like:

var DividerBlot external 'DividerBlot ': Variant;

asm
   class @DividerBlot extends @BlockEmbed { }
end;

DividerBlot .blotName := 'bold';
DividerBlot .tagName := 'strong';

However the above contains an ugly asm section and the DividerBlot variable has to be global.

Thinking about it I did not find any simple way to implement it in DWScript at the moment. Eventually some compiler magic could help. Something like:

var DividerBlot := Extends(BlockEmbed);

which converts the above statement magically to

class DividerBlot extends BlockEmbed { }

but given the fact that the above statement also defines (sets) DividerBlot implicitly it's probably quite complicated.

Or eventually some existing, but hidden RTL code can be tweaked to do the trick of extending the class in ES5 already?!

Comments (0)

  1. Log in to comment