Re: GJS camelCase methods (at least)
- From: philip chimento gmail com
- To: Andrea Giammarchi <andrea giammarchi gmail com>, javascript-list <javascript-list gnome org>
- Subject: Re: GJS camelCase methods (at least)
- Date: Sun, 15 Oct 2017 09:28:51 +0000
Hi Andrea,
I've updated to GJS 1.50 (and I've seen 1.54 is actually the latest) and things are becoming better and better on daily basis.
I appreciate it! 1.50 is the latest stable though, there's certainly no 1.54.
Seeing that I can also extends Gtk classes without needing the (obsolete?) Lang namespace is wonderful, yet beside having almost fully implemented ES2015 syntax I've seen zero changes in terms of "camelCasization".
I've created a method that does only that [1] so that I can write code like the following one and see it working without a glitch.
```js
const Gtk = imports.gi.Gtk;
Gtk.init(null);
class Dialog extends camelPatched(Gtk.Window) {
constructor(...args) {
super(...args);
this.connect('show', () => {
this.setKeepAbove(true);
Gtk.main();
});
this.connect('destroy', () => Gtk.main_quit());
}
}
const win = new Dialog({
type: Gtk.WindowType.TOPLEVEL,
window_position: Gtk.WindowPosition.CENTER
});
win.setDefaultSize(200, 80);
win.add(new Gtk.Label({label: 'Hello GJS!'}));
win.showAll();
```
Now, I understand that properties and configuration objects might require huge time/resources investment but can we please consider a migration plan for at least camelCase methods?
Or could we at least add a method that does basically exactly the same thing I am doing so that GJS could offer a more JS friendly environment?
Thanks in advance for any sort of outcome.
We did discuss this already on the mailing list. My thoughts have not changed in the meantime: I agree it's inconsistent but essentially a cosmetic problem. I would welcome, and gladly code-review, a contributed fix, on the condition that it doesn't slow down existing property accesses or mess up stack traces, but I'm not planning to fix it right now myself.
Note that camel case property names and configuration objects really do already work as far as I know!
If you would like to pick this task up, I think it can be done in object_instance_resolve() in gi/object.cpp without slowing down existing accesses. The tedious part might be adding regression tests and handling weird cases such as get_html -> getHtml vs. getHTML.
Regards,
Philip
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]