Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared user properties #107

Open
uliwitness opened this issue Jun 29, 2021 · 1 comment
Open

Shared user properties #107

uliwitness opened this issue Jun 29, 2021 · 1 comment

Comments

@uliwitness
Copy link
Owner

uliwitness commented Jun 29, 2021

A lot of shared information was traditionally kept in globals in HyperTalk. In modern languages, there are many smaller scopes that you can use to avoid namespace collisions between different modules. We already have user properties as a storage that is namespaced to that instance. (a property "foo" on cd btn 1 can be completely different than one of the same name on cd btn 2)

It seems like it could be a good first step to add something like that to user properties. To provide some sort of "shared" user property that can be addressed just like any other user property, but whose value is shared by multiple objects.

Can we find a good syntax for that? Or is it enough to just tell scripters to create an invisible object to hold all those properties and access them from another?

Maybe something like

create cd btn "sharedStorage"
define property "shared1" of cd btn "sharedStorage"

create cd btn "storageAccessor1"
set sharedPropertyContainer of cd btn "storageAccessor1" to cd btn "sharedStorage"
set shared1 of cd btn "storageAccessor1" to 42 -- actually changes shared1 of cd btn "sharedStorage"

?

One major advantage of this would be the brevity of saying my shared1 inside "storageAccessor1"'s script instead of having to write shared1 of cd btn "sharedStorage". Of course it could also be surprising if there was a "storageAccessor2" whose shared1 property would suddenly also change.

@uliwitness
Copy link
Owner Author

uliwitness commented Jun 29, 2021

Bonus thought: Could this be made a general mechanism, where not just user properties, but the entire script of the sharedStorage is inherited? Kind of a blueprint/class style deal? Or would that be mixing apples and oranges? Given the script would often also need to access non-shared properties, how would you conveniently declare those if they aren't inherited? Why would they be shared and not copied/inherited?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant