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

Integrate "Bean(...)" Functionality in "include(...)" #1097

Open
madoar opened this issue Aug 23, 2019 · 6 comments
Open

Integrate "Bean(...)" Functionality in "include(...)" #1097

madoar opened this issue Aug 23, 2019 · 6 comments

Comments

@madoar
Copy link
Collaborator

madoar commented Aug 23, 2019

After our latest changes to the include(...) operation the syntax of Bean(...) and include(...) are very similar to each other. Both operations take an id string and return an object containing the loaded functionality.

The only difference between both operations seems to be the composition of the passed id string and whether the returned object was defined in Java or JavaScript. Because of this I think we can integrate the functionality of Bean in the include operation. To help include decide whether the to be included script is defined in Java or JS we can add a bean. prefix to the passed id.

So if you want to include the extractor bean you would need to call:

const Extractor = include("bean.extractor");

instead of:

const Extractor = Bean("extractor");

@plata @qparis @ImperatorS79 what do you think?

@plata
Copy link
Collaborator

plata commented Aug 24, 2019

Fine for me.

One thing that might be a bit confusing: Normally, the Bean gives you an object while the include gives you a class.

@madoar
Copy link
Collaborator Author

madoar commented Aug 24, 2019

Normally, the Bean gives you an object while the include gives you a class.

This is actually not the case, include gives you an object. This object can be a class, an array a string or anything else. In JS every class is an object.

@ImperatorS79
Copy link
Contributor

I think I prefer const Extractor = Bean("extractor"); because you directly see what it is.

@plata
Copy link
Collaborator

plata commented Aug 25, 2019

This is actually not the case, include gives you an object. This object can be a class, an array a string or anything else. In JS every class is an object.

I was referring to the way you use the returned object. For include, you usually call new... before you do something.

@ImperatorS79 the question is: do we really want to see that it's a difference? Actually, you might very well implement the beans in JS directly. So maybe we should not even use that term at all and rather call it something like "built-ins".

@madoar
Copy link
Collaborator Author

madoar commented Aug 25, 2019

For include, you usually call new... before you do something.

We have also included scripts that are used differently. For example our file utilities or the wine engine version strings.

@plata
Copy link
Collaborator

plata commented Aug 26, 2019

That's true.

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

3 participants