sphere-group / pegasus

The Pegasus API for Sphere 2.0
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Engine-specific functions: a rule #12

Closed joskuijpers closed 10 years ago

joskuijpers commented 10 years ago

Today I was working on my implementation of Buffer, which will be using Typed Arrays. I would like to allow my users to directly pass a Typed Array to create a Buffer. But to keep Pegasus working without TA, this can't be in Pegasus.

That brought my mind by the point I am trying to make: lets prefix engine-specific functions so they are easy to see and to make it possible to add them to Pegasus later.

I am claiming amd for Andromeda. I suggest ts for TurboSphere and sfml for SFML but you are free in that.

My function to retrieve the Typed Array from a buffer would be:\

Buffer.prototype.amd_getTypedArray() {
    return internalArray;
};

Users can easily check if such function exists and use them. Using the engine class they can see what engine they run on.

Any thoughts are welcome.

FlyingJester commented 10 years ago

This is sort of categorically strange for TurboSphere to abide by. The `engine' exposes only five functions.

joskuijpers commented 10 years ago

Not the engine, but also the system scripts?

FlyingJester commented 10 years ago

Well, it makes sense for us to claim 2-4 letter object/namespaces or so.

I just can't guarantee that TS won't be running plugins that provide non-standard functions from plugins. I can say that certain TS-specific functions (with all likelihood, plugin handling functions) could be very logically placed in a ts object.

But...just to keep up with what I've done previously, I also would like to claim the object black_mamba. Older TS releases had secret test functions hidden in that.

joskuijpers commented 10 years ago

Alright, but that is quite fine. One could also double prefix like tssql, it doesnt really matter. It is just important that it is very clear to users what code is pegasus and will work on all engines, and what is vendor specific.