Skip to main content

News

Topic: Object.defineProperty in Sphere 1.5? (Read 4192 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Object.defineProperty in Sphere 1.5?
I'm currently unable to access my Windows laptop that has Sphere 1.5 on it; can someone with easier access to their 1.5 setup confirm whether or not the Object.defineProperty method of getters & setters works? I know much of my old Sphere code uses older getters and setters tactics and I'd much rather recommend something more modern and standardized to those who want to raise their JS level.

Re: Object.defineProperty in Sphere 1.5?
Reply #1
The Linux and Macintosh 1.6+ versions I have don't have it to be sure, and I pumped the libjs version in my OS X version as high as it would go before API breakage.

So I doubt it.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Object.defineProperty in Sphere 1.5?
Reply #2
No, it does not.  Sphere 1.5 uses JS 1.5, an incredibly ancient version of SpiderMonkey (2003 according to Sphere editor's About dialog).
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Object.defineProperty in Sphere 1.5?
Reply #3
Lord English, I noticed you do this sometimes:

Code: (javascript) [Select]

function object() {
    this.something = getter function() {
    }
}


Which is interesting since my ECMA 1.5 compliant SSFML doesn't see that as valid syntax (SpiderMonkey has it's quirks). You could use __defineSetter__() or __defineGetter()__... But again I only added that as a polyfill utilizing Object.defineProperty... so I guess that originally didn't work either, but at least it's a bit more compatible since I'm not keen on adding extra syntax handling to Jurassic's lexical analyzer (const was enough!).
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Object.defineProperty in Sphere 1.5?
Reply #4
Yeah, prop getter/setter is a non-standard Mozilla way to do it in older SpiderMonkey versions before defineProperty was a thing. It doesn't work anymore in SM either, so no use getting worked up over it.  If you see that, it's older code I wrote; I try to avoid it now.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: Object.defineProperty in Sphere 1.5?
Reply #5
So...yea, three different ways to get/set, but only one is current standard.

Can someone with more time than me get a working Object.defineProperty polyfill? I'm fine with it being prototyped directly onto Object.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Object.defineProperty in Sphere 1.5?
Reply #6
It's pretty much impossible to polyfill, so much of its functionality requires hooks in the underlying JS engine that older engines just don't have.  Even MDN doesn't list a polyfill for it.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub