Hi, We need a syntax that allows determining the dependencies unambiguously from the AST. ES 6 module import syntax allows for that, Qt.import doesn't unfortunately.
Simon From: Chris Adams Sent: Tuesday, February 17, 2015 09:31 To: Mike Verdone Cc: development@qt-project.org Subject: Re: [Development] Proposed syntax change for pragmas and imports in QtQuick .js files Hi, On Mon, Feb 16, 2015 at 11:34 PM, Mike Verdone <mike.verd...@ableton.com<mailto:mike.verd...@ableton.com>> wrote: Hi all, This is my first post to the Qt dev list. Apologies if I say something dumb. I'd like to propose some changes to the "meta" syntax in QtQuick .js files. I propose this in order to support JavaScript tools such as linters and "transpilers". Specifically I'd like to change: .pragma singleton to "pragma singleton"; and .import "foo.js" as Foo to var Foo = Qt.import("foo.js"); This one is a bit tricky, as that sort of statement "looks" like it could be placed anywhere within a given imperative scope, but for .js files in QML we'd probably require that such such import only occur at the start of the file (otherwise such a statement might require invalidation of the evaluation scope, recompilation of the unit, triggering of all bindings which reference the import, and so on). On the other hand, it would have one major advantage: being able to inject symbols into the initial evaluation scope of the import at import time, via: var Foo = Qt.import("foo.js", { "Window": someObj, "Image": function() { ... } }); etc, which is something which cannot be done right now, and, in my opinion, is the biggest barrier to adding support for the vast majority of 3rd party JS libraries in QML. We really should add support for "pragma threaded" again, too. Cheers, Chris. In the first example, the pragma is changed to something that standard JavaScript can parse and ignore. It matches nicely with the ECMAScript "use strict"; syntax. For the import statement, I could also apply the same string-like syntax trick, but building an actual Qt.import function allows programs to detect that the new variable is available in the global scope. The "." meta syntax should be preserved for backwards compatibility. Making these changes opens QtQuick's JS to a whole new world of JavaScript libraries and tools. For instance, .js files can be validated with ESLint for correctness. Tools like the 6to5 allow one to write ES6 JavaScript right now, and transpile it to QtQuick-compatible ES5 JavaScript. I'm not expecting any of you busy Qt developers to take on this work. I'm just curious if these changes might be accepted if I manage to implement them, or if you have other ideas for how to enable tools like linters to process QtQuick JS. Thanks, Mike. - Mike Verdone Ableton AG Schoenhauser Allee 6-7 10119 Berlin, Germany Vorstand: Gerhard Behles, Jan Bohl, Bernd Roggendorf Aufsichtsrat: Uwe Struck (Vorsitzender) Sitz: Amtsgericht Berlin-Charlottenburg HRB 72838 Umsatzsteueridentifikationsnummer: DE204128565 _______________________________________________ Development mailing list Development@qt-project.org<mailto:Development@qt-project.org> http://lists.qt-project.org/mailman/listinfo/development www.qinetic.com.au<http://www.qinetic.com.au> - Qt And QML User Experience Specialists On Mon, Feb 16, 2015 at 11:34 PM, Mike Verdone <mike.verd...@ableton.com<mailto:mike.verd...@ableton.com>> wrote: Hi all, This is my first post to the Qt dev list. Apologies if I say something dumb. I'd like to propose some changes to the "meta" syntax in QtQuick .js files. I propose this in order to support JavaScript tools such as linters and "transpilers". Specifically I'd like to change: .pragma singleton to "pragma singleton"; and .import "foo.js" as Foo to var Foo = Qt.import("foo.js"); In the first example, the pragma is changed to something that standard JavaScript can parse and ignore. It matches nicely with the ECMAScript "use strict"; syntax. For the import statement, I could also apply the same string-like syntax trick, but building an actual Qt.import function allows programs to detect that the new variable is available in the global scope. The "." meta syntax should be preserved for backwards compatibility. Making these changes opens QtQuick's JS to a whole new world of JavaScript libraries and tools. For instance, .js files can be validated with ESLint for correctness. Tools like the 6to5 allow one to write ES6 JavaScript right now, and transpile it to QtQuick-compatible ES5 JavaScript. I'm not expecting any of you busy Qt developers to take on this work. I'm just curious if these changes might be accepted if I manage to implement them, or if you have other ideas for how to enable tools like linters to process QtQuick JS. Thanks, Mike. - Mike Verdone Ableton AG Schoenhauser Allee 6-7 10119 Berlin, Germany Vorstand: Gerhard Behles, Jan Bohl, Bernd Roggendorf Aufsichtsrat: Uwe Struck (Vorsitzender) Sitz: Amtsgericht Berlin-Charlottenburg HRB 72838 Umsatzsteueridentifikationsnummer: DE204128565 _______________________________________________ Development mailing list Development@qt-project.org<mailto:Development@qt-project.org> http://lists.qt-project.org/mailman/listinfo/development
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development